mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
mobile: fix editor stuck in loading state
This commit is contained in:
@@ -68,7 +68,7 @@ export const openNote = async (item, isTrash, setSelectedItem, isSheet) => {
|
||||
clearSelection();
|
||||
}
|
||||
|
||||
if (_note.conflicted) {
|
||||
if (!_note.conflicted) {
|
||||
eSendEvent(eShowMergeDialog, _note);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -128,6 +128,7 @@ const Editor = React.memo(
|
||||
const onError = useCallback(() => {
|
||||
renderKey.current =
|
||||
renderKey.current === `editor-0` ? `editor-1` : `editor-0`;
|
||||
editor.state.current.ready = false;
|
||||
editor.setLoading(true);
|
||||
}, [editor]);
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ const EditorOverlay = ({ editorId = "", editor }) => {
|
||||
translateValue.value = 0;
|
||||
timers.current.error = setTimeout(() => {
|
||||
setError(true);
|
||||
}, 15 * 1000);
|
||||
}, 60 * 1000);
|
||||
} else {
|
||||
clearTimers();
|
||||
const timeDiffSinceLoadStarted =
|
||||
@@ -109,7 +109,7 @@ const EditorOverlay = ({ editorId = "", editor }) => {
|
||||
clearTimers();
|
||||
eUnSubscribeEvent("loadingNote" + editorId, load);
|
||||
};
|
||||
}, [editorId, load, translateValue]);
|
||||
}, [editorId, load, translateValue, opacity]);
|
||||
|
||||
const animatedStyle = useAnimatedStyle(() => {
|
||||
return {
|
||||
|
||||
@@ -369,6 +369,10 @@ export const useEditor = (
|
||||
} else {
|
||||
overlay(true);
|
||||
}
|
||||
if (!state.current.ready) {
|
||||
currentNote.current = item as NoteType;
|
||||
return;
|
||||
}
|
||||
lastContentChangeTime.current = item.dateEdited;
|
||||
const nextSessionId = makeSessionId(item as NoteType);
|
||||
lockedSessionId.current = nextSessionId;
|
||||
@@ -595,7 +599,7 @@ export const useEditor = (
|
||||
|
||||
const onReady = useCallback(async () => {
|
||||
if (!(await isEditorLoaded(editorRef, sessionIdRef.current))) {
|
||||
eSendEvent("webview_reset", "reset");
|
||||
eSendEvent("webview_reset");
|
||||
} else {
|
||||
isDefaultEditor && restoreEditorState();
|
||||
}
|
||||
@@ -611,13 +615,13 @@ export const useEditor = (
|
||||
);
|
||||
await commands.setSessionId(sessionIdRef.current);
|
||||
await onReady();
|
||||
state.current.ready = true;
|
||||
await commands.setSettings();
|
||||
if (currentNote.current) {
|
||||
loadNote({ ...currentNote.current, forced: true });
|
||||
} else {
|
||||
await commands.setPlaceholder(placeholderTip.current);
|
||||
}
|
||||
state.current.ready = true;
|
||||
}, 1000);
|
||||
}, [
|
||||
onReady,
|
||||
|
||||
@@ -67,7 +67,7 @@ export async function isEditorLoaded(
|
||||
ref: RefObject<WebView>,
|
||||
sessionId: string
|
||||
) {
|
||||
return await post(ref, sessionId, EditorEvents.status, undefined, 150);
|
||||
return await post(ref, sessionId, EditorEvents.status);
|
||||
}
|
||||
|
||||
export async function post<T>(
|
||||
|
||||
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import {
|
||||
AppState,
|
||||
KeyboardAvoidingView,
|
||||
@@ -47,11 +47,18 @@ export const EditorWrapper = ({ width }) => {
|
||||
(state) => state.settings.introCompleted
|
||||
);
|
||||
const keyboard = useKeyboard();
|
||||
const prevState = useRef();
|
||||
|
||||
const onAppStateChanged = async (state) => {
|
||||
if (!prevState.current) {
|
||||
prevState.current = state;
|
||||
return;
|
||||
}
|
||||
if (state === "active") {
|
||||
editorController.current.onReady();
|
||||
editorController.current.overlay(false);
|
||||
} else {
|
||||
prevState.current = state;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user