Split initialization into separate effects and focus note after load
This commit is contained in:
@@ -916,17 +916,23 @@ const Index = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load initial notes and scratch
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const init = async () => {
|
const initIndexes = async () => {
|
||||||
await initializeIndexes();
|
await initializeIndexes();
|
||||||
|
};
|
||||||
|
initIndexes();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadInitialData = async () => {
|
||||||
if (isInitialized) {
|
if (isInitialized) {
|
||||||
await loadNotes();
|
await loadNotes();
|
||||||
await loadLatestScratch();
|
await loadLatestScratch();
|
||||||
await loadFontSizeSetting();
|
await loadFontSizeSetting();
|
||||||
|
currentNoteRef.current?.focus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
init();
|
loadInitialData();
|
||||||
}, [isInitialized]);
|
}, [isInitialized]);
|
||||||
|
|
||||||
// Helper function to format date in yyyy-MM-dd hh:mm:ss format
|
// Helper function to format date in yyyy-MM-dd hh:mm:ss format
|
||||||
|
Reference in New Issue
Block a user