Skip to content

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

handle incomplete sync

ammarahm-ed39dd7e7cd6d1
diff --git a/apps/mobile/src/components/listitems/note/wrapper.js b/apps/mobile/src/components/listitems/note/wrapper.js
index 87b48e708..7bdd7b5f1 100644
--- a/apps/mobile/src/components/listitems/note/wrapper.js
+++ b/apps/mobile/src/components/listitems/note/wrapper.js
@@ -18,6 +18,15 @@ export const openNote = async (item, isTrash, setSelectedItem) => {
_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'
+ });
+ return;
+ }
+
if (history.selectedItemsList.length > 0 && history.selectionMode) {
setSelectedItem && setSelectedItem(_note);
return;
diff --git a/apps/mobile/src/screens/notebook/index.js b/apps/mobile/src/screens/notebook/index.js
index e6d604b02..d0f795f25 100644
--- a/apps/mobile/src/screens/notebook/index.js
+++ b/apps/mobile/src/screens/notebook/index.js
@@ -12,12 +12,11 @@ import SearchService from '../../services/search';
import { InteractionManager } from '../../utils';
import { db } from '../../utils/database';
import { eOnNewTopicAdded, eOpenAddNotebookDialog, eOpenAddTopicDialog } from '../../utils/events';
-
+import { qclone } from 'qclone';
export const Notebook = ({ route, navigation }) => {
const [topics, setTopics] = useState(
- groupArray(route?.params.notebook?.topics || [], db.settings.getGroupOptions('topics'))
+ groupArray(qclone(route?.params.notebook?.topics) || [], db.settings.getGroupOptions('topics'))
);
- console.log('params', route?.params.notebook?.topics);
const params = useRef(route?.params);
const onLoad = data => {
@@ -26,7 +25,7 @@ export const Notebook = ({ route, navigation }) => {
let notebook = db.notebooks.notebook(params?.current?.notebook?.id)?.data;
if (notebook) {
params.current.notebook = notebook;
- setTopics(groupArray(notebook.topics, db.settings.getGroupOptions('topics')));
+ setTopics(groupArray(qclone(notebook.topics), db.settings.getGroupOptions('topics')));
params.current.title = params.current.notebook.title;
}
updateSearch();
@@ -38,7 +37,7 @@ export const Notebook = ({ route, navigation }) => {
return () => {
eUnSubscribeEvent(eOnNewTopicAdded, onLoad);
};
- }, []);
+ }, [topics]);
const onFocus = async () => {
InteractionManager.runAfterInteractions(() => {