-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Update] Curtainから表示に関係ない部分を別フックに新たに切り出し
- Loading branch information
Showing
11 changed files
with
121 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { atom } from "recoil" | ||
import { ProviderSettingState } from "@/types/ProviderSettingState" | ||
|
||
export const spotifySettingStateAtom = atom<ProviderSettingState>({ | ||
key: "spotifySettingStateAtom", | ||
default: "none" | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { atom } from "recoil" | ||
import { ProviderSettingState } from "@/types/ProviderSettingState" | ||
|
||
export const webDAVSettingStateAtom = atom<ProviderSettingState>({ | ||
key: "webDAVSettingStateAtom", | ||
default: "none" | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useEffect } from "react" | ||
import { useAuthState } from "react-firebase-hooks/auth" | ||
import { useSetRecoilState } from "recoil" | ||
import useSetSpotifySettingState from "./useSetSpotifySettingState" | ||
import useSpotifyApi from "./useSpotifyApi" | ||
import useSpotifyToken from "./useSpotifyToken" | ||
import useSetWebDAVSettingState from "./useWebDAVSettingState" | ||
import { faviconIndexAtom } from "@/atoms/faviconIndexAtom" | ||
import { LOCAL_STORAGE_KEYS } from "@/constants/LocalStorageKeys" | ||
import { auth } from "@/utils/firebase" | ||
import { generateRandomNumber } from "@/utils/randomNumberGenerator" | ||
|
||
const useInitializer = () => { | ||
/** MixJuiceを開いた時に実行したい、かつ表示に直接関係ない処理はこのフック内で行う TODO: ログインチェックなど */ | ||
|
||
const [user, loading] = useAuthState(auth) | ||
|
||
useSpotifyApi({ initialize: true }) | ||
useSpotifyToken({ initialize: true }) | ||
|
||
useSetSpotifySettingState({ isLoadingUser: loading }) | ||
useSetWebDAVSettingState({ isLoadingUser: loading }) | ||
|
||
const setFaviconIndex = useSetRecoilState(faviconIndexAtom) | ||
useEffect(() => { | ||
setFaviconIndex(generateRandomNumber(1, 12)) | ||
}, [setFaviconIndex]) | ||
|
||
/** 不要説 */ | ||
useEffect(() => { | ||
const localStorageDataFormatVersion = localStorage.getItem( | ||
LOCAL_STORAGE_KEYS.LOCAL_STORAGE_DATA_FORMAT_VERSION | ||
) | ||
|
||
if (!localStorageDataFormatVersion) { | ||
localStorage.setItem( | ||
LOCAL_STORAGE_KEYS.LOCAL_STORAGE_DATA_FORMAT_VERSION, | ||
"1" | ||
) | ||
} | ||
}, []) | ||
|
||
return { user, isLoadingUser: loading } as const | ||
} | ||
|
||
export default useInitializer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters