From 073bf9452884afe12cdb35a86ef06438ea00a355 Mon Sep 17 00:00:00 2001 From: Jun Murakami <126404131+Jun-Murakami@users.noreply.github.com> Date: Wed, 22 May 2024 21:10:51 +0900 Subject: [PATCH] =?UTF-8?q?React=E3=82=B3=E3=83=B3=E3=83=9D=E3=83=BC?= =?UTF-8?q?=E3=83=8D=E3=83=B3=E3=83=88=E3=81=A8=E3=83=95=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4=E3=82=92=E5=8A=A0=E3=81=88=E3=81=BE?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/HomePage.tsx | 12 +++++++++++- src/hooks/useAuth.ts | 6 +----- 2 files changed, 12 insertions(+), 6 deletions(-) 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();