Fix login hanging

This commit is contained in:
Arthur Belleville 2025-10-16 20:06:58 +02:00
parent 4bf78a0c01
commit 760e364815
No known key found for this signature in database
3 changed files with 4 additions and 5 deletions

View file

@ -1,4 +1,3 @@
import { useSession } from "@ui/contexts/SessionContext";
import { useEffect, useState } from "react";
import { Navigate, Outlet } from "react-router-dom";
import { match } from "ts-pattern";
@ -11,7 +10,7 @@ interface ProtectedRouteProps {
}
export const ProtectedRoute = ({ fallback, shouldRedirectToCurrentPage }: ProtectedRouteProps) => {
const { session } = useSession();
const user = useMaybeUser();
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
@ -19,11 +18,10 @@ export const ProtectedRoute = ({ fallback, shouldRedirectToCurrentPage }: Protec
setIsLoading(false);
}, 200);
return () => clearTimeout(timer);
}, [session, fallback]);
}, [user, fallback]);
let status: "loading" | "should-land-user" | "should-redirect" | "should-pass" = "loading";
const user = useMaybeUser();
const isFirstTimeUser = localStorage.getItem("xtablo-has-seen-landing-page") === null;
if (isLoading) {

View file

@ -17,6 +17,7 @@ export const useSession = () => {
};
type Props = { children: React.ReactNode };
export const SessionProvider = ({ children }: Props) => {
const [session, setSession] = useState<Session | null>(null);

View file

@ -7,7 +7,7 @@ export const api = axios.create({
headers: {
"Content-Type": "application/json",
},
timeout: 8000,
timeout: 2000,
});
// Create React Query client with default options