Skip gql subscriptions until auth is properly set up
This commit is contained in:
@@ -124,7 +124,9 @@ const InitialBackgroundRequests = () => {
|
|||||||
* and thus, data of existing chapters/mangas in the cache get outdated
|
* and thus, data of existing chapters/mangas in the cache get outdated
|
||||||
*/
|
*/
|
||||||
const BackgroundSubscriptions = () => {
|
const BackgroundSubscriptions = () => {
|
||||||
const skipConnection = !AuthManager.useIsAuthenticated();
|
const { isAuthRequired, accessToken } = AuthManager.useSession();
|
||||||
|
|
||||||
|
const skipConnection = isAuthRequired === null || (isAuthRequired && !accessToken);
|
||||||
|
|
||||||
requestManager.useDownloadSubscription({ skip: skipConnection });
|
requestManager.useDownloadSubscription({ skip: skipConnection });
|
||||||
requestManager.useUpdaterSubscription({ skip: skipConnection });
|
requestManager.useUpdaterSubscription({ skip: skipConnection });
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useSyncExternalStore } from 'react';
|
import { useMemo, useSyncExternalStore } from 'react';
|
||||||
import { AppStorage } from '@/lib/storage/AppStorage.ts';
|
import { AppStorage } from '@/lib/storage/AppStorage.ts';
|
||||||
|
|
||||||
let notifierValue = 0;
|
let notifierValue = 0;
|
||||||
@@ -52,13 +52,22 @@ export class AuthManager {
|
|||||||
} {
|
} {
|
||||||
useSyncExternalStore(AuthManager.subscribe.bind(AuthManager), () => notifierValue);
|
useSyncExternalStore(AuthManager.subscribe.bind(AuthManager), () => notifierValue);
|
||||||
|
|
||||||
return {
|
return useMemo(
|
||||||
accessToken: AuthManager.accessToken,
|
() => ({
|
||||||
refreshToken: AuthManager.getRefreshToken(),
|
accessToken: AuthManager.accessToken,
|
||||||
isAuthRequired: AuthManager.authRequired,
|
refreshToken: AuthManager.getRefreshToken(),
|
||||||
isInitialized: AuthManager.authInitialized,
|
isAuthRequired: AuthManager.authRequired,
|
||||||
isRefreshingToken: AuthManager.refreshingToken,
|
isInitialized: AuthManager.authInitialized,
|
||||||
};
|
isRefreshingToken: AuthManager.refreshingToken,
|
||||||
|
}),
|
||||||
|
[
|
||||||
|
AuthManager.accessToken,
|
||||||
|
AuthManager.getRefreshToken(),
|
||||||
|
AuthManager.authRequired,
|
||||||
|
AuthManager.authInitialized,
|
||||||
|
AuthManager.refreshingToken,
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static useIsAuthenticated(): boolean {
|
static useIsAuthenticated(): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user