From 760e364815947b5962fe71c647584153663fd207 Mon Sep 17 00:00:00 2001 From: Arthur Belleville Date: Thu, 16 Oct 2025 20:06:58 +0200 Subject: [PATCH] Fix login hanging --- ui/src/components/ProtectedRoute.tsx | 6 ++---- ui/src/contexts/SessionContext.tsx | 1 + ui/src/lib/api.ts | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ui/src/components/ProtectedRoute.tsx b/ui/src/components/ProtectedRoute.tsx index 46e389c..014d7ec 100644 --- a/ui/src/components/ProtectedRoute.tsx +++ b/ui/src/components/ProtectedRoute.tsx @@ -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) { diff --git a/ui/src/contexts/SessionContext.tsx b/ui/src/contexts/SessionContext.tsx index ad3958c..9bbb2c4 100644 --- a/ui/src/contexts/SessionContext.tsx +++ b/ui/src/contexts/SessionContext.tsx @@ -17,6 +17,7 @@ export const useSession = () => { }; type Props = { children: React.ReactNode }; + export const SessionProvider = ({ children }: Props) => { const [session, setSession] = useState(null); diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.ts index dbf62c3..e2a112d 100644 --- a/ui/src/lib/api.ts +++ b/ui/src/lib/api.ts @@ -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