From dc85e938bd8905412da22e978f34b242ac989bb2 Mon Sep 17 00:00:00 2001 From: unclekingpin Date: Thu, 20 Jul 2023 15:19:29 -0700 Subject: [PATCH] navigate to intro when the state actually changes --- src/App/App.js | 4 ---- src/App/withProtectedRoutes.js | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/App/App.js b/src/App/App.js index 6aac8b950..f0752dc3f 100644 --- a/src/App/App.js +++ b/src/App/App.js @@ -97,10 +97,6 @@ const App = () => { React.useEffect(() => { const onCoreEvent = ({ event, args }) => { switch (event) { - case 'UserLoggedOut': { - window.location = '#/intro'; - break; - } case 'SettingsUpdated': { if (args && args.settings && typeof args.settings.interfaceLanguage === 'string') { i18n.changeLanguage(args.settings.interfaceLanguage); diff --git a/src/App/withProtectedRoutes.js b/src/App/withProtectedRoutes.js index bfd775d89..5532a08aa 100644 --- a/src/App/withProtectedRoutes.js +++ b/src/App/withProtectedRoutes.js @@ -7,6 +7,13 @@ const { useProfile } = require('stremio/common'); const withProtectedRoutes = (Component) => { return function withProtectedRoutes(props) { const profile = useProfile(); + const previousProfileRef = React.useRef(null); + React.useEffect(() => { + if (previousProfileRef.current?.auth !== null && profile.auth === null) { + window.location = '#/intro'; + } + previousProfileRef.current = profile; + }, [profile]) const onRouteChange = React.useCallback((routeConfig) => { if (profile.auth !== null && routeConfig.component === Intro) { window.location.replace('#/');