From 4054d5294036a687a8dc3f0e98293499b0a31e16 Mon Sep 17 00:00:00 2001 From: gurusainath Date: Wed, 1 May 2024 19:12:17 +0530 Subject: [PATCH] chore: handled auth wrapper --- web/lib/wrappers/authentication-wrapper.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/web/lib/wrappers/authentication-wrapper.tsx b/web/lib/wrappers/authentication-wrapper.tsx index b775c87c4..f13e28e57 100644 --- a/web/lib/wrappers/authentication-wrapper.tsx +++ b/web/lib/wrappers/authentication-wrapper.tsx @@ -1,4 +1,5 @@ import { FC, ReactNode } from "react"; +import { observer } from "mobx-react"; import { useRouter } from "next/router"; import useSWR from "swr"; import { Spinner } from "@plane/ui"; @@ -19,7 +20,7 @@ const isValidURL = (url: string): boolean => { return !disallowedSchemes.test(url); }; -export const AuthenticationWrapper: FC = (props) => { +export const AuthenticationWrapper: FC = observer((props) => { const router = useRouter(); const { next_path } = router.query; // props @@ -34,7 +35,7 @@ export const AuthenticationWrapper: FC = (props) => { } = useUser(); const { loader: workspaceLoader, workspaces, fetchWorkspaces } = useWorkspace(); - useSWR("USER_INFORMATION", () => fetchCurrentUser(), { + useSWR("USER_INFORMATION", async () => fetchCurrentUser(), { revalidateOnFocus: false, shouldRetryOnError: false, }); @@ -42,7 +43,7 @@ export const AuthenticationWrapper: FC = (props) => { useSWR( currentUser && currentUser?.id ? "USER_PROFILE_SETTINGS_INFORMATION" : null, async () => { - if (currentUser) { + if (currentUser && currentUser?.id) { fetchCurrentUserSettings(); fetchUserProfile(); fetchWorkspaces(); @@ -126,4 +127,4 @@ export const AuthenticationWrapper: FC = (props) => { } return <>{children}; -}; +});