diff --git a/src/App.tsx b/src/App.tsx index d59d3b35..5744851b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -103,20 +103,13 @@ const ScrollToTop = () => { }; const InitialBackgroundRequests = () => { - const { isAuthRequired, accessToken } = AuthManager.useSession(); - const skipConnection = isAuthRequired == null || (!isAuthRequired && !accessToken); - const [fetchExtensionList] = requestManager.useExtensionListFetch(); useEffect(() => { - if (skipConnection) { - return; - } - // Fetch extension list on startup to show up-to-date number of available extension updates in the navigation bar // without having to open the extensions page. fetchExtensionList().catch(defaultPromiseErrorHandler('App::InitialBackgroundRequests: extension list')); - }, [skipConnection]); + }, []); return null; }; @@ -128,10 +121,7 @@ const InitialBackgroundRequests = () => { * and thus, data of existing chapters/mangas in the cache get outdated */ const BackgroundSubscriptions = () => { - // Listen to session changes - const { isAuthRequired, accessToken } = AuthManager.useSession(); - - const skipConnection = isAuthRequired == null || (!isAuthRequired && !accessToken); + const skipConnection = !AuthManager.useIsAuthenticated(); // Load the full download status once on startup to fill the cache requestManager.useGetDownloadStatus({ nextFetchPolicy: 'standby' }); @@ -153,9 +143,8 @@ const ReactRouterSetter = () => { }; const PrivateRoutes = () => { - const { isAuthRequired, accessToken, refreshToken } = AuthManager.useSession(); + const isAuthenticated = AuthManager.useIsAuthenticated(); - const isAuthenticated = !isAuthRequired || (isAuthRequired && (accessToken || refreshToken)); if (!isAuthenticated) { return ( { const { t } = useTranslation(); const { setOverride } = useNavBarContext(); const navigate = useNavigate(); - const { isAuthRequired, accessToken, refreshToken } = AuthManager.useSession(); + const isAuthenticated = AuthManager.useIsAuthenticated(); const [redirect] = useQueryParam(SearchParam.REDIRECT, StringParam); const [loginUser, { loading: isLoading }] = requestManager.useLoginUser(); @@ -38,8 +38,6 @@ export const LoginPage = () => { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); - const isAuthenticated = !isAuthRequired || (isAuthRequired && !!accessToken && !!refreshToken); - const doLogin = async () => { try { const { data } = await loginUser({ variables: { username, password } });