From fcb24ec5a0898b984b2f8eb4c92ae6d0620e78c5 Mon Sep 17 00:00:00 2001 From: Deepak Paul Date: Tue, 8 Aug 2023 00:57:55 +0530 Subject: [PATCH] fix: on page reload Insights page redirecting to Dashboard --- layouts/private-wrapper.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/layouts/private-wrapper.tsx b/layouts/private-wrapper.tsx index 170d51be00..8f57530bd6 100644 --- a/layouts/private-wrapper.tsx +++ b/layouts/private-wrapper.tsx @@ -1,4 +1,4 @@ -import { useUser } from "@supabase/auth-helpers-react"; +import { useSessionContext, useUser } from "@supabase/auth-helpers-react"; import { useRouter } from "next/router"; import React, { useEffect } from "react"; import useSession from "lib/hooks/useSession"; @@ -11,12 +11,13 @@ interface PrivateWrapperProps { const PrivateWrapper = ({ isPrivateRoute = false, children }: PrivateWrapperProps) => { const user = useUser(); const router = useRouter(); + const { isLoading } = useSessionContext(); const { session: isValid } = useSession(true); async function checkSession() { if (router.asPath?.includes("login")) return; - if (!isValid) { + if (!isValid && !isLoading) { router.replace("/javascript/dashboard/filter/recent"); } }