Skip to content

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

mobile: check item restored successfully

Ammar Ahmed5c3ad96cbe86
diff --git a/apps/mobile/app/components/list-items/notebook/wrapper.tsx b/apps/mobile/app/components/list-items/notebook/wrapper.tsx
index 7e3ef6f82..ff4e88046 100644
--- a/apps/mobile/app/components/list-items/notebook/wrapper.tsx
+++ b/apps/mobile/app/components/list-items/notebook/wrapper.tsx
@@ -41,7 +41,7 @@ export const openNotebook = (item: Notebook | BaseTrashItem<Notebook>) => {
positiveText: strings.restore(),
negativeText: strings.delete(),
positivePress: async () => {
- await db.trash.restore(item.id);
+ if ((await db.trash.restore(item.id)) === false) return;
Navigation.queueRoutesForUpdate();
useSelectionStore.getState().setSelectionMode(undefined);
ToastManager.show({
diff --git a/apps/mobile/app/components/note-history/preview.js b/apps/mobile/app/components/note-history/preview.js
index 5bb1f447f..52914954c 100644
--- a/apps/mobile/app/components/note-history/preview.js
+++ b/apps/mobile/app/components/note-history/preview.js
@@ -48,7 +48,7 @@ export default function NotePreview({ session, content, note }) {
async function restore() {
if (note && note.type === "trash") {
- await db.trash.restore(note.id);
+ if ((await db.trash.restore(note.id)) === false) return;
Navigation.queueRoutesForUpdate();
useSelectionStore.getState().setSelectionMode(false);
ToastManager.show({
diff --git a/apps/mobile/app/components/selection-header/index.tsx b/apps/mobile/app/components/selection-header/index.tsx
index db9bdfd05..aec2ee903 100644
--- a/apps/mobile/app/components/selection-header/index.tsx
+++ b/apps/mobile/app/components/selection-header/index.tsx
@@ -90,7 +90,7 @@ export const SelectionHeader = React.memo(
const restoreItem = async () => {
if (!selectedItemsList.length) return;
- await db.trash.restore(...selectedItemsList);
+ if ((await db.trash.restore(...selectedItemsList)) === false) return;
Navigation.queueRoutesForUpdate();
clearSelection();
diff --git a/apps/mobile/app/hooks/use-actions.tsx b/apps/mobile/app/hooks/use-actions.tsx
index 585aaef5c..2ecbc343f 100644
--- a/apps/mobile/app/hooks/use-actions.tsx
+++ b/apps/mobile/app/hooks/use-actions.tsx
@@ -141,7 +141,7 @@ export const useActions = ({
async function restoreTrashItem() {
if (!checkItemSynced()) return;
close();
- await db.trash.restore(item.id);
+ if ((await db.trash.restore(item.id)) === false) return;
Navigation.queueRoutesForUpdate();
const type = item.type === "trash" ? item.itemType : item.type;
ToastManager.show({
diff --git a/apps/mobile/app/utils/functions.js b/apps/mobile/app/utils/functions.js
index 6680758c6..0e57688c0 100644
--- a/apps/mobile/app/utils/functions.js
+++ b/apps/mobile/app/utils/functions.js
@@ -135,7 +135,7 @@ export const deleteItems = async (items, type, context) => {
heading: message,
type: "success",
func: async () => {
- await db.trash.restore(...deletedIds);
+ if ((await db.trash.restore(...deletedIds)) === false) return;
Navigation.queueRoutesForUpdate();
useMenuStore.getState().setMenuPins();
useMenuStore.getState().setColorNotes();