Skip to content

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

mobile: loading note gets stuck

Ammar Ahmed8d9df5030cfb
diff --git a/apps/mobile/app/screens/editor/index.tsx b/apps/mobile/app/screens/editor/index.tsx
index 621dedda3..3a383dec9 100755
--- a/apps/mobile/app/screens/editor/index.tsx
+++ b/apps/mobile/app/screens/editor/index.tsx
@@ -25,7 +25,8 @@ import React, {
useEffect,
useImperativeHandle,
useLayoutEffect,
- useRef
+ useRef,
+ useState
} from "react";
import { Platform, ViewStyle } from "react-native";
import WebView from "react-native-webview";
@@ -109,17 +110,20 @@ const Editor = React.memo(
noToolbar,
noHeader
});
- const renderKey = useRef(randId("editor-id") + editorId);
+ const [renderKey, setRenderKey] = useState(
+ randId("editor-id") + editorId
+ );
useImperativeHandle(ref, () => ({
get: () => editor
}));
useLockedNoteHandler();
const onError = useCallback(() => {
- renderKey.current = randId("editor-id") + editorId;
+ setRenderKey(randId("editor-id") + editorId);
editor.state.current.ready = false;
+ editor.state.current.initialLoadCalled = false;
editor.setLoading(true);
- }, [editor, editorId]);
+ }, [editor]);
useEffect(() => {
const sub = [eSubscribeEvent(eEditorReset, onError)];
@@ -144,7 +148,7 @@ const Editor = React.memo(
<WebView
testID={notesnook.editor.id}
ref={editor.ref}
- key={renderKey.current}
+ key={renderKey}
onRenderProcessGone={onError}
nestedScrollEnabled
onError={onError}
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
index aa351882a..1e718f1c8 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
@@ -684,8 +684,6 @@ export const useEditor = (
lastContentChangeTime.current[item.id] = item.dateEdited;
currentNotes.current[item.id] = item;
- if (!currentNotes.current[item.id]) return;
-
editorSessionHistory.newSession(item.id);
await commands.setStatus(
@@ -1104,6 +1102,8 @@ export const useEditor = (
if (noteId) {
const note = await db.notes?.note(noteId);
fluidTabsRef.current?.goToPage("editor");
+ loadNoteMutex.cancel();
+ loadNoteMutex.release();
if (note) {
loadNote({
item: note
@@ -1111,6 +1111,8 @@ export const useEditor = (
}
} else {
noteId = useTabStore.getState().getCurrentNoteId() || null;
+ loadNoteMutex.cancel();
+ loadNoteMutex.release();
if (!noteId) {
loadNote({ newNote: true });
if (fluidTabsRef.current?.page() === "editor") {