diff --git a/frontend/src/core/providers/UIProvider/index.js b/frontend/src/core/providers/UIProvider/index.js index d20223a8..ffdff2e5 100644 --- a/frontend/src/core/providers/UIProvider/index.js +++ b/frontend/src/core/providers/UIProvider/index.js @@ -32,13 +32,7 @@ const UIProvider = ({ children }) => { const [isLoggedIn, setLoggedIn] = useState(user && user.username); const [isLoggingOut, setLoggingOut] = useState(false); const [isAppReady, setAppReady] = useState(false); - const [isAppView, setAppView] = useState( - router.nextRouter.asPath.includes("/stream") || - router.nextRouter.asPath.includes("/account") || - router.nextRouter.asPath.includes("/subscriptions") || - router.nextRouter.asPath.includes("/analytics") || - router.nextRouter.asPath.includes("/welcome") - ); + const [isAppView, setAppView] = useState(false); useEffect(() => { if (isAppView && isAppReady && !user?.username && !isLoggingOut) { @@ -69,15 +63,6 @@ const UIProvider = ({ children }) => { } }, [user]); - useEffect(() => { - setAppView( - router.nextRouter.asPath.includes("/stream") || - router.nextRouter.asPath.includes("/account") || - router.nextRouter.asPath.includes("/subscriptions") || - router.nextRouter.asPath.includes("/analytics") || - router.nextRouter.asPath.includes("/welcome") - ); - }, [router.nextRouter.asPath, user]); // *********** Sidebar states ********************** diff --git a/frontend/src/layouts/AppLayout.js b/frontend/src/layouts/AppLayout.js index c4bf88ba..78eb322d 100644 --- a/frontend/src/layouts/AppLayout.js +++ b/frontend/src/layouts/AppLayout.js @@ -1,11 +1,21 @@ import { Flex } from "@chakra-ui/react"; import { getLayout as getSiteLayout } from "./RootLayout"; -import React, { useContext } from "react"; +import React, { useContext, useLayoutEffect } from "react"; import UIContext from "../core/providers/UIProvider/context"; const AppLayout = ({ children }) => { const ui = useContext(UIContext); + useLayoutEffect(() => { + if (ui.isAppReady) { + ui.setAppView(true); + return () => { + ui.setAppView(false); + }; + } + //eslint-disable-next-line + }, [ui.isAppReady]); + return (