Skip to content

Commit

Permalink
fix: fetch uiConfig when the user logs in (#3107)
Browse files Browse the repository at this point in the history
This PR will force a refetch of the uiConfig after the user has logged
into the system.
  • Loading branch information
FredrikOseberg committed Feb 14, 2023
1 parent 6c84ebc commit a2499b7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/src/component/App.tsx
@@ -1,4 +1,4 @@
import { Suspense } from 'react';
import { Suspense, useEffect } from 'react';
import { Route, Routes } from 'react-router-dom';
import { ErrorBoundary } from 'react-error-boundary';
import { Error } from 'component/layout/Error/Error';
Expand Down Expand Up @@ -29,6 +29,8 @@ const StyledContainer = styled('div')(() => ({

export const App = () => {
const { authDetails } = useAuthDetails();
const { refetch: refetchUiConfig } = useUiConfig();

const { user } = useAuthUser();
const hasFetchedAuth = Boolean(authDetails || user);

Expand All @@ -38,6 +40,12 @@ export const App = () => {
? routes.filter(route => !route.enterprise)
: routes;

useEffect(() => {
if (hasFetchedAuth && Boolean(user?.id)) {
refetchUiConfig();
}
}, [authDetails, user]);

return (
<ErrorBoundary FallbackComponent={Error}>
<SWRProvider>
Expand Down

0 comments on commit a2499b7

Please sign in to comment.