Skip to content

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

check if trash item is synced

ammarahm-ed566414bf888c
diff --git a/apps/mobile/src/components/listitems/note/wrapper.js b/apps/mobile/src/components/listitems/note/wrapper.js
index 92f84f77b..eff886928 100644
--- a/apps/mobile/src/components/listitems/note/wrapper.js
+++ b/apps/mobile/src/components/listitems/note/wrapper.js
@@ -12,16 +12,25 @@ import { tabBarRef } from '../../../utils/global-refs';
import { presentDialog } from '../../dialog/functions';
import SelectionWrapper from '../selection-wrapper';
+const present = () =>
+ presentDialog({
+ title: 'Note not synced',
+ negativeText: 'Ok',
+ paragraph: 'Please sync again to open this note for editing'
+ });
+
export const openNote = async (item, isTrash, setSelectedItem) => {
let _note = item;
+
if (!isTrash) {
_note = db.notes.note(item.id).data;
if (!db.notes.note(item.id)?.synced()) {
- presentDialog({
- title: 'Note not synced',
- negativeText: 'Ok',
- paragraph: 'Please sync again to open this note for editing'
- });
+ present();
+ return;
+ }
+ } else {
+ if (!db.trash.synced(item.id)) {
+ present();
return;
}
}
diff --git a/apps/mobile/src/utils/hooks/useActions.js b/apps/mobile/src/utils/hooks/useActions.js
index 9837c5bb2..142d00e0d 100644
--- a/apps/mobile/src/utils/hooks/useActions.js
+++ b/apps/mobile/src/utils/hooks/useActions.js
@@ -255,8 +255,9 @@ export const useActions = ({ close = () => {}, item }) => {
}
const checkNoteSynced = () => {
- if (item.type !== 'note') return true;
- if (!db.notes.note(item.id).synced()) {
+ if (item.type !== 'note' || item.itemType !== 'note') return true;
+ let isTrash = item.itemType === 'note';
+ if (!isTrash && !db.notes.note(item.id).synced()) {
ToastEvent.show({
context: 'local',
heading: 'Note not synced',
@@ -265,6 +266,17 @@ export const useActions = ({ close = () => {}, item }) => {
});
return false;
}
+
+ if (isTrash && !db.trash.synced(item.id)) {
+ ToastEvent.show({
+ context: 'local',
+ heading: 'Note not synced',
+ message: 'Please run sync before making changes',
+ type: 'error'
+ });
+ return false;
+ }
+
return true;
};