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: fix delete notebook in bulk
ammarahm-ed2159f6720e7a
diff --git a/apps/mobile/app/components/selection-header/index.js b/apps/mobile/app/components/selection-header/index.jsindex 1b6264d76..197869e0f 100644--- a/apps/mobile/app/components/selection-header/index.js+++ b/apps/mobile/app/components/selection-header/index.js@@ -317,23 +317,8 @@ export const SelectionHeader = React.memo(() => {customStyle={{marginLeft: 10}}- onPress={async () => {- presentDialog({- title: `Delete ${- selectedItemsList.length > 1 ? "items" : "item"- }`,- paragraph: `Are you sure you want to delete ${- selectedItemsList.length > 1 ? "these items?" : "this item?"- }`,- positiveText: "Delete",- negativeText: "Cancel",- positivePress: () => {- deleteItems();- },- positiveType: "errorShade"- });-- return;+ onPress={() => {+ deleteItems();}}tooltipText="Move to trash"tooltipPosition={1}diff --git a/apps/mobile/app/utils/functions.js b/apps/mobile/app/utils/functions.jsindex 32a2f0e34..9bc68848d 100644--- a/apps/mobile/app/utils/functions.js+++ b/apps/mobile/app/utils/functions.js@@ -107,46 +107,43 @@ export const deleteItems = async (item, context) => {if (topics?.length > 0) {const result = await confirmDeleteAllNotes(topics, "topic", context);- if (result.delete) {- for (const topic of topics) {- if (result.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);+ if (!result.delete) return;+ for (const topic of topics) {+ if (result.deleteNotes) {+ const notes = db.notebooks+ .notebook(topic.notebookId)+ .topics.topic(topic.id).all;+ await db.notes.delete(...notes.map((note) => note.id));}- useMenuStore.getState().setMenuPins();- ToastEvent.show({- heading: `${topics.length > 1 ? "Topics" : "Topic"} deleted`,- type: "success"- });+ await db.notebooks.notebook(topic.notebookId).topics.delete(topic.id);}+ useMenuStore.getState().setMenuPins();+ ToastEvent.show({+ heading: `${topics.length > 1 ? "Topics" : "Topic"} deleted`,+ type: "success"+ });}if (notebooks?.length > 0) {const result = await confirmDeleteAllNotes(notebooks, "notebook", context);-- if (result.delete) {- let ids = notebooks.map((i) => i.id);- if (result.deleteNotes) {- for (let id of ids) {- const notebook = db.notebooks.notebook(id);- const topics = notebook.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));- }- const notes = db.relations.from(notebook.data, "note");+ if (!result.delete) return;+ let ids = notebooks.map((i) => i.id);+ if (result.deleteNotes) {+ for (let id of ids) {+ const notebook = db.notebooks.notebook(id);+ const topics = notebook.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));}+ const notes = db.relations.from(notebook.data, "note");+ await db.notes.delete(...notes.map((note) => note.id));}- await db.notebooks.delete(...ids);- useMenuStore.getState().setMenuPins();}+ await db.notebooks.delete(...ids);+ useMenuStore.getState().setMenuPins();}Navigation.queueRoutesForUpdate();