From 344df33f08b981631ba32aed910bf6ed0aba1776 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Sat, 14 Mar 2026 21:15:01 +0500 Subject: [PATCH] mobile: fix editor stops updating notes after first two notes edited --- .../app/screens/editor/tiptap/use-editor.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts index 178cafe90..f1fe871d0 100644 --- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts +++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts @@ -167,7 +167,7 @@ export const useEditor = ( const tags = useTagStore((state) => state.items); const insets = useGlobalSafeAreaInsets(); const isDefaultEditor = editorId === ""; - const saveCount = useRef(0); + const saveCount = useRef>({}); const lastContentChangeTime = useRef>({}); const lock = useRef(false); const currentLoadingNoteId = useRef(undefined); @@ -253,9 +253,9 @@ export const useEditor = ( clearTimeout(timers.current["loading-images" + noteId]); } - saveCount.current = 0; currentLoadingNoteId.current = undefined; lock.current = false; + saveCount.current[tabId] = 0; resetContent && postMessage(NativeEvents.title, "", tabId); resetContent && (await commands.clearContent(tabId)); resetContent && (await commands.clearTags(tabId)); @@ -436,10 +436,9 @@ export const useEditor = ( lastContentChangeTime.current[id] = note.dateEdited; if ( - saveCount.current < 2 || + saveCount.current[tabId] < 2 || currentNotes.current[id]?.title !== note.title || - currentNotes.current[id]?.headline?.slice(0, 200) !== - note.headline?.slice(0, 200) + currentNotes.current[id]?.headline !== note.headline ) { Navigation.queueRoutesForUpdate(); } @@ -455,7 +454,11 @@ export const useEditor = ( currentNotes.current[id] = note; } - saveCount.current++; + if (!saveCount.current[tabId]) { + saveCount.current[tabId] = 1; + } else { + saveCount.current[tabId]++; + } clearTimeout(timers.current.onsave); timers.current.onsave = setTimeout(async () => { @@ -553,6 +556,7 @@ export const useEditor = ( useTabStore.getState().newTabSession(tabId, {}); } } + saveCount.current[tabId] = 0; setTimeout(() => { if (state.current?.ready && !state.current.movedAway) @@ -685,6 +689,7 @@ export const useEditor = ( currentNotes.current[item.id] = item; editorSessionHistory.newSession(item.id); + saveCount.current[tabId] = 0; await commands.setStatus( getFormattedDate(item.dateEdited, "date-time"),