1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-19 01:17:18 +02:00

fix: fetch uiConfig when the user logs in (#3107)

This PR will force a refetch of the uiConfig after the user has logged
into the system.
This commit is contained in:
Fredrik Strand Oseberg 2023-02-14 14:27:26 +01:00 committed by GitHub
parent 6c84ebc8ed
commit a2499b7213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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';
@ -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);
@ -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>