diff --git a/src/components/HomePage.tsx b/src/components/HomePage.tsx index ec7fa55..04f6470 100644 --- a/src/components/HomePage.tsx +++ b/src/components/HomePage.tsx @@ -1,5 +1,6 @@ -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { useAuth } from '../hooks/useAuth'; +import { useIndexedDb } from '../hooks/useIndexedDb'; import { useTreeManagement } from '../hooks/useTreeManagement'; import { ModalDialog } from '../components/ModalDialog'; import { InputDialog } from '../components/InputDialog'; @@ -47,12 +48,21 @@ export function HomePage() { handleDeleteAccount, } = useAuth(); + const { loadSettingsFromIdb } = useIndexedDb(); + const { handleCreateOfflineTree } = useTreeManagement(); const theme = useTheme(); const drawerWidth = 300; + useEffect(() => { + const asyncFunc = async () => { + await loadSettingsFromIdb(); + }; + asyncFunc(); + }, [loadSettingsFromIdb]); + return ( <> {isDialogVisible && } diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts index a59c479..5f696f7 100644 --- a/src/hooks/useAuth.ts +++ b/src/hooks/useAuth.ts @@ -18,7 +18,6 @@ import { getStorage, ref as storageRef, deleteObject, listAll } from 'firebase/s import { Capacitor } from '@capacitor/core'; import { FirebaseAuthentication } from '@capacitor-firebase/authentication'; import { useObserve } from './useObserve'; -import { useIndexedDb } from './useIndexedDb'; import { useAppStateStore } from '../store/appStateStore'; import { useTreeStateStore } from '../store/treeStateStore'; import { useInputDialogStore } from '../store/dialogStore'; @@ -73,14 +72,11 @@ export const useAuth = () => { const showInputDialog = useInputDialogStore((state) => state.showDialog); - const { loadSettingsFromIdb } = useIndexedDb(); // 追加 - const { observeTimeStamp } = useObserve(); // ログイン状態の監視 useEffect(() => { const asyncFunc = async () => { - await loadSettingsFromIdb(); if (Capacitor.isNativePlatform() && FirebaseAuthentication) { FirebaseAuthentication.addListener('authStateChange', async (result) => { if (result.user) { @@ -102,7 +98,7 @@ export const useAuth = () => { }; }; asyncFunc(); - }, [setIsLoading, setIsLoggedIn, setUid, setEmail, loadSettingsFromIdb]); + }, [setIsLoading, setIsLoggedIn, setUid, setEmail]); useEffect(() => { const auth = getAuth();