From 320432bd8c4a25b30bbc8ea87fe3ad8232af561e Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Wed, 6 Aug 2025 17:07:31 +0200 Subject: [PATCH] Split initialization into separate effects and focus note after load --- src/pages/Index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index 87c16d7..699c6d5 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -916,17 +916,23 @@ const Index = () => { } }; - // Load initial notes and scratch useEffect(() => { - const init = async () => { + const initIndexes = async () => { await initializeIndexes(); + }; + initIndexes(); + }, []); + + useEffect(() => { + const loadInitialData = async () => { if (isInitialized) { await loadNotes(); await loadLatestScratch(); await loadFontSizeSetting(); + currentNoteRef.current?.focus(); } }; - init(); + loadInitialData(); }, [isInitialized]); // Helper function to format date in yyyy-MM-dd hh:mm:ss format