mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: authentication wrapper fetch user
This commit is contained in:
parent
1c4a629bda
commit
e1b16208cb
@ -27,9 +27,9 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = observer((props
|
|||||||
const { children, pageType = EPageTypes.AUTHENTICATED } = props;
|
const { children, pageType = EPageTypes.AUTHENTICATED } = props;
|
||||||
// hooks
|
// hooks
|
||||||
const { isLoading: isUserLoading, data: currentUser, fetchCurrentUser } = useUser();
|
const { isLoading: isUserLoading, data: currentUser, fetchCurrentUser } = useUser();
|
||||||
const { isLoading: currentUserProfileLoader, data: currentUserProfile } = useUserProfile();
|
const { isLoading: isUserProfileLoading, data: currentUserProfile, fetchUserProfile } = useUserProfile();
|
||||||
const { isLoading: currentUserSettingsLoader, data: currentUserSettings } = useUserSettings();
|
const { isLoading: isUserSettingsLoading, data: currentUserSettings, fetchCurrentUserSettings } = useUserSettings();
|
||||||
const { loader: workspaceLoader, workspaces, fetchWorkspaces } = useWorkspace();
|
const { loader: isWorkspaceLoading, workspaces, fetchWorkspaces } = useWorkspace();
|
||||||
|
|
||||||
useSWR("USER_INFORMATION", async () => await fetchCurrentUser(), {
|
useSWR("USER_INFORMATION", async () => await fetchCurrentUser(), {
|
||||||
revalidateOnFocus: false,
|
revalidateOnFocus: false,
|
||||||
@ -38,7 +38,10 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = observer((props
|
|||||||
|
|
||||||
useSWR(
|
useSWR(
|
||||||
currentUser && currentUser?.id ? "USER_PROFILE_SETTINGS_INFORMATION" : null,
|
currentUser && currentUser?.id ? "USER_PROFILE_SETTINGS_INFORMATION" : null,
|
||||||
async () => currentUser && currentUser?.id && (await fetchWorkspaces()),
|
async () => {
|
||||||
|
if (currentUser && currentUser?.id)
|
||||||
|
await Promise.all([fetchUserProfile(), fetchCurrentUserSettings(), fetchWorkspaces()]);
|
||||||
|
},
|
||||||
{ revalidateOnFocus: false, shouldRetryOnError: false }
|
{ revalidateOnFocus: false, shouldRetryOnError: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -65,7 +68,7 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = observer((props
|
|||||||
return redirectionRoute;
|
return redirectionRoute;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isUserLoading || currentUserProfileLoader || currentUserSettingsLoader || workspaceLoader)
|
if (isUserLoading || isUserProfileLoading || isUserSettingsLoading || isWorkspaceLoading)
|
||||||
return (
|
return (
|
||||||
<div className="relative flex h-screen w-full items-center justify-center">
|
<div className="relative flex h-screen w-full items-center justify-center">
|
||||||
<Spinner />
|
<Spinner />
|
||||||
|
Loading…
Reference in New Issue
Block a user