From 18cc3d3dd50fb71237f5ee00202569e6e77b8dd3 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Fri, 28 Feb 2025 11:43:34 +0500 Subject: [PATCH] mobile: fix editor state not restored sometimes on app launch --- apps/mobile/app/navigation/fluid-panels-view.tsx | 2 +- apps/mobile/app/screens/editor/tiptap/use-editor.ts | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/mobile/app/navigation/fluid-panels-view.tsx b/apps/mobile/app/navigation/fluid-panels-view.tsx index 62fb5cd68..3454f207c 100644 --- a/apps/mobile/app/navigation/fluid-panels-view.tsx +++ b/apps/mobile/app/navigation/fluid-panels-view.tsx @@ -107,7 +107,7 @@ export const FluidPanelsView = React.memo( if (!appLoading) { setTimeout(() => { setIsLoading(false); - }, 1000); + }, 500); } }, [appLoading]); diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts index d9faad8b5..f52c54b61 100644 --- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts +++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts @@ -998,7 +998,6 @@ export const useEditor = ( if (fluidTabsRef.current?.page() === "editor") { state.current.movedAway = false; } - if (!state.current.editorStateRestored) { state.current.isRestoringState = true; if (!DDS.isTab) { @@ -1076,12 +1075,12 @@ export const useEditor = ( let noteId = url && new URL(url).searchParams.get("id"); if (noteId) { const note = await db.notes?.note(noteId); + fluidTabsRef.current?.goToPage("editor"); if (note) { loadNote({ item: note }); } - fluidTabsRef.current?.goToPage("editor"); } else { noteId = useTabStore.getState().getCurrentNoteId() || null; if (!noteId) { @@ -1091,6 +1090,7 @@ export const useEditor = ( } } else { const note = await db.notes.note(noteId); + restoreEditorState(); if (note) { loadNote({ item: note @@ -1102,13 +1102,14 @@ export const useEditor = ( overlay(false); } }, [ - postMessage, - theme, commands, isDefaultEditor, insets, + postMessage, + theme, + overlay, loadNote, - overlay + restoreEditorState ]); return {