From eba7341d45ca4c76d00a08908d53173e07aa870e Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Sat, 23 Nov 2024 22:14:14 +0500 Subject: [PATCH] mobile: restore editor state only if not restored already --- apps/mobile/app/screens/editor/tiptap/types.ts | 1 + apps/mobile/app/screens/editor/tiptap/use-editor.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/mobile/app/screens/editor/tiptap/types.ts b/apps/mobile/app/screens/editor/tiptap/types.ts index eec6cc4332..f1b22f0f93 100644 --- a/apps/mobile/app/screens/editor/tiptap/types.ts +++ b/apps/mobile/app/screens/editor/tiptap/types.ts @@ -37,6 +37,7 @@ export type EditorState = { scrollPosition: number; overlay?: boolean; initialLoadCalled?: boolean; + editorStateRestored?: boolean; }; export type Settings = { diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts index 11fae5e036..261fb2db82 100644 --- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts +++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts @@ -861,9 +861,13 @@ export const useEditor = ( state.current.currentlyEditing = true; state.current.movedAway = false; - if (!DDS.isTab) { - tabBarRef.current?.goToPage(1, false); + if (!state.current.editorStateRestored) { + state.current.isRestoringState = true; + if (!DDS.isTab) { + tabBarRef.current?.goToPage(1, false); + } } + clearAppState(); state.current.isRestoringState = false; }, []);