Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: migrate from delete to removeFromNotebook

ammarahm-ed67fb1bc1da41
diff --git a/apps/mobile/app/components/selection-header/index.js b/apps/mobile/app/components/selection-header/index.js
index f3d7234ce..7a66de926 100644
--- a/apps/mobile/app/components/selection-header/index.js
+++ b/apps/mobile/app/components/selection-header/index.js
@@ -246,10 +246,14 @@ export const SelectionHeader = React.memo(() => {
if (selectedItemsList.length > 0) {
const currentTopic =
useNavigationStore.getState().currentScreen;
- await db.notebooks
- .notebook(currentTopic.notebookId)
- .topics.topic(currentTopic.id)
- .delete(...selectedItemsList.map((item) => item.id));
+ await db.notes.removeFromNotebook(
+ {
+ id: currentTopic.notebookId,
+ topic: currentTopic.id
+ },
+ ...selectedItemsList.map((item) => item.id)
+ );
+
Navigation.queueRoutesForUpdate(
"Notes",
"Favorites",
diff --git a/apps/mobile/app/components/sheets/add-to/index.js b/apps/mobile/app/components/sheets/add-to/index.js
index bd110143e..a726687fe 100644
--- a/apps/mobile/app/components/sheets/add-to/index.js
+++ b/apps/mobile/app/components/sheets/add-to/index.js
@@ -151,15 +151,19 @@ const MoveNoteComponent = ({ note }) => {
: [note?.id];
if (getCount(item)) {
- await db.notebooks
- .notebook(item.notebookId)
- .topics.topic(item.id)
- .delete(...noteIds);
+ await db.notes.removeFromNotebook(
+ {
+ id: item.notebookId,
+ topic: item.id
+ },
+ ...noteIds
+ );
} else {
- await db.notes.move(
+ await db.notes.addToNotebook(
{
topic: item.id,
- id: item.notebookId
+ id: item.notebookId,
+ rebuildCache: true
},
...noteIds
);
diff --git a/apps/mobile/app/hooks/use-actions.js b/apps/mobile/app/hooks/use-actions.js
index af947cfa6..60d63b12d 100644
--- a/apps/mobile/app/hooks/use-actions.js
+++ b/apps/mobile/app/hooks/use-actions.js
@@ -480,10 +480,13 @@ export const useActions = ({ close = () => null, item }) => {
async function removeNoteFromTopic() {
const currentScreen = useNavigationStore.getState().currentScreen;
if (currentScreen.name !== "TopicNotes") return;
- await db.notebooks
- .notebook(currentScreen.notebookId)
- .topics.topic(currentScreen.id)
- .delete(item.id);
+ await db.notes.removeFromNotebook(
+ {
+ id: currentScreen.notebookId,
+ topic: currentScreen.id
+ },
+ item.id
+ );
Navigation.queueRoutesForUpdate(
"TaggedNotes",
"ColoredNotes",