import { useEffect, useState } from "react"; import { useAvatarStore } from "src/Stores"; import useAutoSignIn from "src/avatar/useAutoSignIn"; const useSession = () => { const { loadTotem, totem } = useAvatarStore(); const [isLoading, setLoading] = useState(true); const autoSignIn = useAutoSignIn(); useEffect(() => { (async () => { await loadTotem(); setLoading(false); })(); }, [loadTotem]); useEffect(() => { (async () => { if (!isLoading && !totem) { await autoSignIn(); } })(); }, [autoSignIn, isLoading, totem]); return isLoading; }; export default useSession;