From fc5b62ba6114f96358290009d7030beb78a71a95 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Sat, 29 Apr 2023 06:17:01 +0500 Subject: [PATCH] mobile: remove editor flicker on app launch --- apps/mobile/app/screens/editor/loading.js | 3 ++- apps/mobile/app/screens/editor/tiptap/use-editor.ts | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/mobile/app/screens/editor/loading.js b/apps/mobile/app/screens/editor/loading.js index 18bef8f97..e0565773c 100644 --- a/apps/mobile/app/screens/editor/loading.js +++ b/apps/mobile/app/screens/editor/loading.js @@ -101,8 +101,9 @@ const EditorOverlay = ({ editorId = "", editor }) => { setTimeout(() => { if (!loadingState.current.startTime) { translateValue.value = 6000; + opacity.value = 0; } - }, 1000); + }, 3000); eSubscribeEvent("loadingNote" + editorId, load); return () => { clearTimers(); diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts index be4fbcc0c..00fb89838 100644 --- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts +++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts @@ -340,7 +340,6 @@ export const useEditor = ( ) => { state.current.currentlyEditing = true; const editorState = useEditorStore.getState(); - if (item && item.type === "new") { currentNote.current && (await reset()); const nextSessionId = makeSessionId(item as NoteType); @@ -348,7 +347,7 @@ export const useEditor = ( sessionIdRef.current = nextSessionId; sessionHistoryId.current = Date.now(); await commands.setSessionId(nextSessionId); - await commands.focus(); + if (state.current?.ready) await commands.focus(); lastContentChangeTime.current = 0; useEditorStore.getState().setReadonly(false); } else { @@ -362,7 +361,7 @@ export const useEditor = ( !currentContent.current?.data || currentContent.current?.data.length < 50000 ) { - overlay(false); + if (state.current.ready) overlay(false); } else { overlay(true); }