From 58a3400a35729577135a9a7753338d288eefcf5a Mon Sep 17 00:00:00 2001 From: loucass003 Date: Wed, 30 Sep 2026 00:06:28 +0200 Subject: [PATCH] Fix redirects issues --- gui/app/src/components/AppStatusGate.tsx | 45 ++++++++++++++++++++---- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/gui/app/src/components/AppStatusGate.tsx b/gui/app/src/components/AppStatusGate.tsx index a74c3b28f..3b044878c 100644 --- a/gui/app/src/components/AppStatusGate.tsx +++ b/gui/app/src/components/AppStatusGate.tsx @@ -1,16 +1,33 @@ +import { useEffect, useState } from 'react'; import { Navigate, Outlet, useLocation } from 'react-router-dom'; import { useWebsocketAPI } from '@/hooks/websocket-api'; import { useErrorReporting } from '@/hooks/error-reporting'; +import { ConnectionLost } from './onboarding/pages/ConnectionLost'; +import { ErrorReportingConsentPage } from './ErrorReportingConsent'; export const CONNECTING_PATH = '/connecting'; export const ERROR_REPORTING_CONSENT_PATH = '/error-reporting-consent'; const STATUS_PATHS = [CONNECTING_PATH, ERROR_REPORTING_CONSENT_PATH]; +interface ReturnTo { + path: string; + state: unknown; +} + +function StatusPage({ path }: { path: string }) { + return path === ERROR_REPORTING_CONSENT_PATH ? ( + + ) : ( + + ); +} + export function AppStatusGate() { const { isConnected } = useWebsocketAPI(); const { needsAnswer } = useErrorReporting(); const location = useLocation(); + const [appShown, setAppShown] = useState(false); const statusPath = needsAnswer ? ERROR_REPORTING_CONSENT_PATH @@ -18,15 +35,29 @@ export function AppStatusGate() { ? CONNECTING_PATH : null; const onStatusPath = STATUS_PATHS.includes(location.pathname); - const returnTo: string = onStatusPath - ? (location.state?.returnTo ?? '/') - : location.pathname + location.search; - if (statusPath && location.pathname !== statusPath) { + useEffect(() => { + if (!statusPath && !onStatusPath) setAppShown(true); + }, [statusPath, onStatusPath]); + + const returnTo: ReturnTo = onStatusPath + ? (location.state?.returnTo ?? { path: '/', state: null }) + : { path: location.pathname + location.search, state: location.state }; + + if (!appShown && statusPath && location.pathname !== statusPath) { return ; } - if (!statusPath && onStatusPath) { - return ; + if ((appShown || !statusPath) && onStatusPath) { + return ; } - return ; + + const covering = appShown ? statusPath : null; + return ( + <> + {covering && } +
+ +
+ + ); }