From 81f3e824ff2d52e740054daffb2bc263e8ea3788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Mon, 11 Apr 2022 07:21:20 -0700 Subject: [PATCH] Fixes public apps page (#2422) --- apps/web/components/Shell.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/web/components/Shell.tsx b/apps/web/components/Shell.tsx index 2464f0f7..a9ece1da 100644 --- a/apps/web/components/Shell.tsx +++ b/apps/web/components/Shell.tsx @@ -57,9 +57,10 @@ function useRedirectToLoginIfUnauthenticated() { const { data: session, status } = useSession(); const loading = status === "loading"; const router = useRouter(); + const shouldDisplayUnauthed = router.pathname.startsWith("/apps"); useEffect(() => { - if (router.pathname.startsWith("/apps")) { + if (shouldDisplayUnauthed) { return; } @@ -76,6 +77,7 @@ function useRedirectToLoginIfUnauthenticated() { return { loading: loading && !session, + shouldDisplayUnauthed, session, }; } @@ -134,7 +136,7 @@ export default function Shell(props: { }) { const { t } = useLocale(); const router = useRouter(); - const { loading, session } = useRedirectToLoginIfUnauthenticated(); + const { loading, shouldDisplayUnauthed } = useRedirectToLoginIfUnauthenticated(); const { isRedirectingToOnboarding } = useRedirectToOnboardingIfNeeded(); const telemetry = useTelemetry(); @@ -207,7 +209,7 @@ export default function Shell(props: { ); } - if (!session) return null; + if (!shouldDisplayUnauthed) return null; return ( <>