From c70f3b9a8e7f25050f6e3b35014f67611ad8dbeb Mon Sep 17 00:00:00 2001 From: Jun Murakami <126404131+Jun-Murakami@users.noreply.github.com> Date: Mon, 13 May 2024 00:03:50 +0900 Subject: [PATCH] =?UTF-8?q?useObserve=E3=83=95=E3=83=83=E3=82=AF=E3=81=AE?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E3=82=92=E8=BF=BD=E5=8A=A0***?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useObserve.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hooks/useObserve.ts b/src/hooks/useObserve.ts index 514acbd..84e934a 100644 --- a/src/hooks/useObserve.ts +++ b/src/hooks/useObserve.ts @@ -39,7 +39,6 @@ export const useObserve = () => { const { syncDb, checkAndSyncDb, loadSettingsFromIdb, - loadQuickMemoFromIdb, loadTreesListFromIdb, saveItemsIdb, saveTreesListIdb, @@ -59,7 +58,7 @@ export const useObserve = () => { await checkAndSyncDb(); await loadSettingsFromIdb(); await loadTreesListFromIdb(); - await loadQuickMemoFromIdb(); + await loadQuickMemoFromDb(); setIsLoading(false); // ローカルストレージからitems_offlineとtreeName_offline、quick_memo_offlineを読み込む const { value: itemsOffline } = await Preferences.get({ key: `items_offline` }); @@ -92,6 +91,7 @@ export const useObserve = () => { const serverTimestamp = snapshot.val(); const currentLocalTimestamp = useAppStateStore.getState().localTimestamp; if (serverTimestamp && serverTimestamp > currentLocalTimestamp) { + if (!isLoading) setIsLoading(true); setLocalTimestamp(serverTimestamp); const newTreesList = await loadTreesListFromDb(uid); setTreesList(newTreesList); @@ -101,6 +101,7 @@ export const useObserve = () => { const treeIds = newTreesList.map((tree) => tree.id); let treeUpdateCount = 0; for (const treeId of treeIds) { + if (!isLoading) setIsLoading(true); const treeRef = ref(getDatabase(), `trees/${treeId}`); await get(treeRef).then(async (snapshot) => { if (snapshot.exists()) { @@ -113,6 +114,7 @@ export const useObserve = () => { }); } if (treeUpdateCount == 0) { + if (!isLoading) setIsLoading(true); const timestampV2Ref = ref(getDatabase(), `users/${uid}/timestampV2`); await get(timestampV2Ref).then(async (snapshot) => { if (snapshot.exists()) { @@ -125,6 +127,7 @@ export const useObserve = () => { } const currentTree = useTreeStateStore.getState().currentTree; if (currentTree) { + if (!isLoading) setIsLoading(true); setPrevCurrentTree(null); await loadCurrentTreeData(currentTree); }