A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: optionally delete notes with notebook/topic
ammarahm-ed388570ca8e9b
diff --git a/apps/mobile/app/hooks/use-actions.js b/apps/mobile/app/hooks/use-actions.jsindex 680f89578..3e033049e 100644--- a/apps/mobile/app/hooks/use-actions.js+++ b/apps/mobile/app/hooks/use-actions.js@@ -486,6 +486,7 @@ export const useActions = ({ close = () => null, item }) => {} else {try {close();+ await sleep(300);await deleteItems(item);} catch (e) {console.error(e);diff --git a/apps/mobile/app/utils/functions.js b/apps/mobile/app/utils/functions.jsindex fa4473eb7..f28c627d2 100644--- a/apps/mobile/app/utils/functions.js+++ b/apps/mobile/app/utils/functions.js@@ -27,8 +27,29 @@ import { useMenuStore } from "../stores/use-menu-store";import { db } from "../common/database";import { eClearEditor } from "./events";import { useRelationStore } from "../stores/use-relation-store";+import { presentDialog } from "../components/dialog/functions";++function deleteNotesConfirmDialog(items, type, context) {+ return new Promise((resolve) => {+ presentDialog({+ title: "Delete Contained Notes?",+ paragraph: `Do you want to delete notes within ${+ items.length > 1 ? `these ${type}s` : `this ${type}`+ }?`,+ positiveText: "Yes",+ negativeText: "No",+ positivePress: () => {+ resolve(true);+ },+ onClose: () => {+ resolve(false);+ },+ context: context+ });+ });+}-export const deleteItems = async (item) => {+export const deleteItems = async (item, context) => {if (item && db.monographs.isPublished(item.id)) {ToastEvent.show({heading: "Can not delete note",@@ -86,19 +107,47 @@ export const deleteItems = async (item) => {}if (topics?.length > 0) {+ const deleteNotes = await deleteNotesConfirmDialog(+ topics,+ "topic",+ context+ );for (const topic of topics) {+ if (deleteNotes) {+ const notes = db.notebooks+ .notebook(topic.notebookId)+ .topics.topic(topic.id).all;+ await db.notes.delete(...notes.map((note) => note.id));+ }await db.notebooks.notebook(topic.notebookId).topics.delete(topic.id);}routesForUpdate.push("Notebook", "Notebooks");useMenuStore.getState().setMenuPins();ToastEvent.show({- heading: "Topics deleted",+ heading: `${topics.length > 1 ? "Topics" : "Topic"} deleted`,type: "success"});}if (notebooks?.length > 0) {+ const deleteNotes = await deleteNotesConfirmDialog(+ notebooks,+ "notebook",+ context+ );+let ids = notebooks.map((i) => i.id);+ if (deleteNotes) {+ for (let id of ids) {+ const topics = db.notebooks.notebook(id).topics.all;+ for (let topic of topics) {+ const notes = db.notebooks+ .notebook(topic.notebookId)+ .topics.topic(topic.id).all;+ await db.notes.delete(...notes.map((note) => note.id));+ }+ }+ }await db.notebooks.delete(...ids);routesForUpdate.push("Notebook", "Notebooks");useMenuStore.getState().setMenuPins();