mobile: loading note gets stuck

This commit is contained in:
Ammar Ahmed
2026-02-05 11:41:54 +05:00
parent af014cf8c1
commit 8d9df5030c
2 changed files with 13 additions and 7 deletions

View File

@@ -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}

View File

@@ -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") {