Skip to content

Commit

Permalink
feat: show a warning before replacing current drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewinci committed Mar 17, 2023
1 parent 6cfe121 commit 8bb8363
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const App = () => {

const onDelete = async (drawing: Drawing) => {
openModal({
title: "Are you sure?",
title: "Deleting drawing",
description: `Are you sure you want to delete ${drawing.name}?\nThis action is not reversible.`,
icons: "OkIgnore",
onSubmit: (response) => {
Expand All @@ -66,7 +66,7 @@ const App = () => {
const onUpdate = async () => {
const rawDrawing = await getDrawing();
openModal({
title: "Are you sure?",
title: "Update drawing",
description: `Are you sure you want to update ${activeDrawingName?.name}?`,
icons: "OkIgnore",
onSubmit: async (response) => {
Expand All @@ -83,9 +83,24 @@ const App = () => {
});
}

const onOpen = async (drawing: Drawing) => {
openModal({
title: "Open drawing",
description: `Are you sure you want to open ${activeDrawingName?.name}? Any unsaved changes to the current doc will be lost.`,
icons: "OkIgnore",
onSubmit: async (response) => {
if (response === 'Ok') {
await setDrawing(drawing.data, drawing);
}
closeModal();
}
});

}

if (!isAlive) {
return <Modal
title="Are you on the Excalidraw website?"
title="Excalistore"
description={`This extensions only works on the Excalidraw website.\nMake sure to navigate to https://excalidraw.com/ before trying to use this extension.`}
opened={true}
icons={"OK"}
Expand All @@ -111,8 +126,7 @@ const App = () => {
name={d.name}
date={d.lastUpdate}
onDelete={() => onDelete(d)}
//todo: this needs a warning to the user
onOpen={async () => await setDrawing(d.data, d)}
onOpen={async () => await onOpen(d)}
/>)}
</div>
<Modal {...modalProps} />
Expand Down

0 comments on commit 8bb8363

Please sign in to comment.