Skip to content

Commit

Permalink
mobile: restore editor state only if not restored already
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Nov 23, 2024
1 parent 08bd36d commit eba7341
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions apps/mobile/app/screens/editor/tiptap/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type EditorState = {
scrollPosition: number;
overlay?: boolean;
initialLoadCalled?: boolean;
editorStateRestored?: boolean;
};

export type Settings = {
Expand Down
8 changes: 6 additions & 2 deletions apps/mobile/app/screens/editor/tiptap/use-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}, []);
Expand Down

0 comments on commit eba7341

Please sign in to comment.