Revert "Revert "Fixes public apps page (#2422)" (#2461)" (#2462)

This reverts commit a5522c98a0.
This commit is contained in:
Omar López 2022-04-11 08:36:21 -07:00 committed by GitHub
parent a5522c98a0
commit 95af0fb631
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 (
<>