diff --git a/node/landing-page/src/App.tsx b/node/landing-page/src/App.tsx index e52a11bd..5b9b1f3b 100644 --- a/node/landing-page/src/App.tsx +++ b/node/landing-page/src/App.tsx @@ -15,7 +15,7 @@ import { Loading } from './components/Loading'; import { LoginButton } from './components/LoginButton'; // global state to be kept between render calls -let initialized = false; +const [initialized, setInitialized] = useState(false); let initialAppName = ''; let initialAppDefinition = ''; let keycloakConfig: KeycloakConfig | undefined = undefined; @@ -124,14 +124,15 @@ function App(): JSX.Element { setToken(keycloak.idToken); setEmail(userMail); setLogoutUrl(keycloak.createLogoutUrl()); + setInitialized(true); } } }) .catch(() => { console.error('Authentication Failed'); + setError('Authentication failed'); }); } - initialized = true; } useEffect(() => { @@ -150,8 +151,7 @@ function App(): JSX.Element { } if (selectedAppDefinition && gitUri) { - console.log('Checking auth, setting autoStart to true and starting session'); - authenticate(); + console.log('Setting autoStart to true and starting session'); setAutoStart(true); handleStartSession(selectedAppDefinition); } else { @@ -197,6 +197,7 @@ function App(): JSX.Element { setLoading(true); setError(undefined); + // first check if the service is available. if not we are doing maintenance and should adapt the error message accordingly TheiaCloud.ping(PingRequest.create(config.serviceUrl, config.appId)) .then(() => { @@ -296,6 +297,7 @@ function App(): JSX.Element { 'Sorry, we are performing some maintenance at the moment.\n' + "Please try again later. Usually maintenance won't last longer than 60 minutes.\n\n" ); + setError(_err.message); setLoading(false); }); };