Skip to content

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

mobile: fix editor state not restored sometimes on app launch

Ammar Ahmede66365592485
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 {