From 2c8d6d115c8e3b80f2f93dde296eb28f69199656 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Mon, 5 Dec 2022 18:54:44 +0500 Subject: [PATCH] mobile: use content from merged item to update editor --- apps/mobile/app/screens/editor/tiptap/use-editor.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts index 852465436..598387d90 100644 --- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts +++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts @@ -371,8 +371,9 @@ export const useEditor = ( if (!currentNote.current || noteId !== currentNote.current.id) return; const isContentEncrypted = typeof (data as Content)?.data === "object"; const note = db.notes?.note(currentNote.current?.id).data as NoteType; - - if (lastContentChangeTime.current >= note.dateEdited) return; + + if (lastContentChangeTime.current >= (data as NoteType).dateEdited) + return; lock.current = true; if (data.type === "tiptap") { @@ -389,11 +390,11 @@ export const useEditor = ( currentContent.current = decryptedContent; } } else { - const _nextContent = await db.content?.raw(note.contentId); + const _nextContent = data.data; if (_nextContent === currentContent.current?.data) return; lastContentChangeTime.current = note.dateEdited; - await postMessage(EditorEvents.updatehtml, _nextContent.data); - currentContent.current = _nextContent; + await postMessage(EditorEvents.updatehtml, _nextContent); + currentContent.current = data; } } else { const note = data as NoteType;