diff --git a/apps/web/src/common/selectionoptions.js b/apps/web/src/common/selectionoptions.js index da767d35c..8600fe331 100644 --- a/apps/web/src/common/selectionoptions.js +++ b/apps/web/src/common/selectionoptions.js @@ -6,7 +6,7 @@ import { store as editorStore } from "../stores/editor-store"; import { store as trashStore } from "../stores/trash-store"; import { db } from "./index"; import { showMoveNoteDialog } from "../components/dialogs/movenotedialog"; -import { showDeleteConfirmation } from "../components/dialogs/confirm"; +import { showMultiDeleteConfirmation } from "../components/dialogs/confirm"; import { showExportDialog } from "../components/dialogs/exportdialog"; import { showToast } from "../utils/toast"; @@ -31,7 +31,7 @@ const DeleteOption = createOption( async function (state) { const item = state.selectedItems[0]; - if (!(await showDeleteConfirmation(item.type, true))) return; + if (!(await showMultiDeleteConfirmation(item.type))) return; var isAnyNoteOpened = false; const items = state.selectedItems.map((item) => { diff --git a/apps/web/src/components/dialogs/confirm.js b/apps/web/src/components/dialogs/confirm.js index 837206f2c..b5ce59b17 100644 --- a/apps/web/src/components/dialogs/confirm.js +++ b/apps/web/src/components/dialogs/confirm.js @@ -49,33 +49,6 @@ export function confirm( )); } -/** - * - * @param {"note"|"notebook"} type - */ -export function showDeleteConfirmation(type, multi = false) { - let noun = type === "note" ? "Note" : "Notebook"; - if (multi) noun += "s"; - let lowerCaseNoun = noun.toLowerCase(); - - let secondPronoun = multi ? "they" : "it"; - - return confirm(Icon.Trash, { - title: `Delete ${noun}?`, - message: ( - - The {lowerCaseNoun} will be{" "} - - kept in your Trash for 7 days - {" "} - after which {secondPronoun} will be permanently removed. - - ), - yesText: `Delete ${lowerCaseNoun}`, - noText: "Cancel", - }); -} - export function showMultiDeleteConfirmation(type) { let noun = type === "note" ? "Notes" : "Notebooks"; diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js index 075ea3d4a..b7bb0f9b2 100644 --- a/apps/web/src/components/note/index.js +++ b/apps/web/src/components/note/index.js @@ -3,7 +3,6 @@ import { Flex, Text } from "rebass"; import * as Icon from "../icons"; import TimeAgo from "timeago-react"; import ListItem from "../list-item"; -import { confirm, showDeleteConfirmation } from "../dialogs/confirm"; import { showMoveNoteDialog } from "../dialogs/movenotedialog"; import { store, useStore } from "../../stores/note-store"; import { showPasswordDialog } from "../dialogs/passworddialog"; @@ -68,33 +67,12 @@ function menuItems(note, context) { visible: context?.type === "topic", title: "Remove from topic", onClick: async () => { - confirm(Icon.Topic, { - title: "Remove Note from Topic", - subtitle: "Are you sure you want to remove the note from this topic?", - yesText: "Remove note", - noText: "Cancel", - message: ( - - - This action does not delete the note. - {" "} - The note will only be removed from this notebook. You will still - be able to{" "} - - access it from Home and other places. - - - ), - }).then(async (res) => { - if (res) { - console.log(context); - await db.notebooks - .notebook(context.value.id) - .topics.topic(context.value.topic) - .delete(note.id); - store.setContext(context); - } - }); + await db.notebooks + .notebook(context.value.id) + .topics.topic(context.value.topic) + .delete(note.id); + store.setContext(context); + await showToast("success", "Note removed from topic!"); }, }, { @@ -110,11 +88,7 @@ function menuItems(note, context) { }); if (!res) return; } - showDeleteConfirmation("note").then(async (res) => { - if (res) { - await store.delete(note.id).then(() => showItemDeletedToast(note)); - } - }); + await store.delete(note.id).then(() => showItemDeletedToast(note)); }, }, ]; diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.js index 2bfebc97a..407a8e348 100644 --- a/apps/web/src/components/notebook/index.js +++ b/apps/web/src/components/notebook/index.js @@ -3,7 +3,6 @@ import { Flex, Text } from "rebass"; import ListItem from "../list-item"; import { store } from "../../stores/notebook-store"; import { store as appStore } from "../../stores/app-store"; -import { showDeleteConfirmation } from "../dialogs/confirm"; import { showItemDeletedToast, showUnpinnedToast } from "../../common/toasts"; import { db } from "../../common"; import * as Icon from "../icons"; @@ -33,14 +32,10 @@ function menuItems(notebook, index) { { title: "Move to trash", color: "red", - onClick: () => { - showDeleteConfirmation("notebook").then(async (res) => { - if (res) { - await store - .delete(notebook.id, index) - .then(() => showItemDeletedToast(notebook)); - } - }); + onClick: async () => { + await store + .delete(notebook.id, index) + .then(() => showItemDeletedToast(notebook)); }, }, ]; diff --git a/apps/web/src/components/topic/index.js b/apps/web/src/components/topic/index.js index 05d952d81..577e5ac8c 100644 --- a/apps/web/src/components/topic/index.js +++ b/apps/web/src/components/topic/index.js @@ -1,11 +1,8 @@ import React from "react"; import ListItem from "../list-item"; -import { confirm } from "../dialogs/confirm"; -import * as Icon from "../icons"; import { db } from "../../common"; import { store } from "../../stores/notebook-store"; import { store as appStore } from "../../stores/app-store"; -import { Text } from "rebass"; import { hashNavigate } from "../../navigation"; const menuItems = (item) => [ @@ -25,30 +22,9 @@ const menuItems = (item) => [ title: "Delete", visible: item.title !== "General", color: "red", - onClick: () => { - confirm(Icon.Trash, { - title: "Delete topic", - subtitle: "Are you sure you want to delete this topic?", - yesText: "Delete topic", - noText: "Cancel", - message: ( - <> - This action is{" "} - - IRREVERSIBLE - - . Deleting this topic{" "} - - will not delete the notes contained in it. - - - ), - }).then(async (res) => { - if (res) { - await db.notebooks.notebook(item.notebookId).topics.delete(item.id); - store.setSelectedNotebookTopics(item.notebookId); - } - }); + onClick: async () => { + await db.notebooks.notebook(item.notebookId).topics.delete(item.id); + store.setSelectedNotebookTopics(item.notebookId); }, }, ];