Skip to content

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

mobile: restore editor state only if not restored already

Ammar Ahmedeba7341d45ca
diff --git a/apps/mobile/app/screens/editor/tiptap/types.ts b/apps/mobile/app/screens/editor/tiptap/types.ts
index eec6cc433..f1b22f0f9 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 11fae5e03..261fb2db8 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;
}, []);