Add authLoading guard to Profile page

This commit is contained in:
2026-03-11 14:58:38 -07:00
parent 41fb6d6195
commit 355b5f7715
+3 -1
View File
@@ -21,6 +21,7 @@ function formatTime(seconds: number) {
export default function Profile() {
const user = useAuthStore((s) => s.user);
const authLoading = useAuthStore((s) => s.isLoading);
const logout = useAuthStore((s) => s.logout);
const loadUser = useAuthStore((s) => s.loadUser);
const navigate = useNavigate();
@@ -39,6 +40,7 @@ export default function Profile() {
const [passwordSuccess, setPasswordSuccess] = useState('');
useEffect(() => {
if (authLoading) return;
if (!user) {
navigate('/login');
return;
@@ -52,7 +54,7 @@ export default function Profile() {
if (h) setGameHistory(h.data);
})
.finally(() => setLoading(false));
}, [user, navigate]); // eslint-disable-line react-hooks/exhaustive-deps
}, [user, authLoading, navigate]); // eslint-disable-line react-hooks/exhaustive-deps
useEffect(() => {
if (!user || loading) return;