Fix userload on signout

This commit is contained in:
Charles Bochet
2024-04-05 21:01:03 +02:00
parent 9f2c9ee76e
commit 0a9c79b3b3
2 changed files with 9 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import { isVerifyPendingState } from '@/auth/states/isVerifyPendingState';
import { workspacesState } from '@/auth/states/workspaces';
import { authProvidersState } from '@/client-config/states/authProvidersState';
import { billingState } from '@/client-config/states/billingState';
import { isClientConfigLoadedState } from '@/client-config/states/isClientConfigLoadedState';
import { isDebugModeState } from '@/client-config/states/isDebugModeState';
import { isSignInPrefilledState } from '@/client-config/states/isSignInPrefilledState';
import { supportChatState } from '@/client-config/states/supportChatState';
@ -165,8 +166,12 @@ export const useAuth = () => {
const supportChat = snapshot.getLoadable(supportChatState).getValue();
const telemetry = snapshot.getLoadable(telemetryState).getValue();
const isDebugMode = snapshot.getLoadable(isDebugModeState).getValue();
const isClientConfigLoaded = snapshot
.getLoadable(isClientConfigLoadedState)
.getValue();
const initialSnapshot = emptySnapshot.map(({ set }) => {
set(isClientConfigLoadedState, isClientConfigLoaded);
set(iconsState, iconsValue);
set(authProvidersState, authProvidersValue);
set(billingState, billing);

View File

@ -28,16 +28,18 @@ export const UserProviderEffect = () => {
const { loading: queryLoading, data: queryData } = useQuery<{
currentUser: User;
}>(GET_CURRENT_USER, { skip: isCurrentUserLoaded });
}>(GET_CURRENT_USER, {
skip: isCurrentUserLoaded,
});
useEffect(() => {
if (!queryLoading) {
setIsLoading(false);
setIsCurrentUserLoaded(true);
}
if (!isDefined(queryData?.currentUser)) return;
setIsCurrentUserLoaded(true);
setCurrentUser(queryData.currentUser);
setCurrentWorkspace(queryData.currentUser.defaultWorkspace);