Skip to content

Commit

Permalink
Merge branch 'main' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jun-Murakami committed May 23, 2024
2 parents 5fdc64b + 073bf94 commit 198242c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 11 additions & 1 deletion src/components/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 && <ModalDialog />}
Expand Down
6 changes: 1 addition & 5 deletions src/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand All @@ -102,7 +98,7 @@ export const useAuth = () => {
};
};
asyncFunc();
}, [setIsLoading, setIsLoggedIn, setUid, setEmail, loadSettingsFromIdb]);
}, [setIsLoading, setIsLoggedIn, setUid, setEmail]);

useEffect(() => {
const auth = getAuth();
Expand Down

0 comments on commit 198242c

Please sign in to comment.