Update dependency "apollo-client" to v4.x
v4.1.6
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { ReactNode } from 'react';
|
||||
import { ReactNode, useEffect } from 'react';
|
||||
import { SplashScreen } from '@/features/authentication/components/SplashScreen.tsx';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { AuthManager } from '@/features/authentication/AuthManager.ts';
|
||||
@@ -14,19 +14,20 @@ import { AuthManager } from '@/features/authentication/AuthManager.ts';
|
||||
export const AuthGuard = ({ children }: { children: ReactNode }) => {
|
||||
const { isAuthRequired } = AuthManager.useSession();
|
||||
|
||||
requestManager.useGetAbout({
|
||||
const { data } = requestManager.useGetAbout({
|
||||
skip: isAuthRequired !== null,
|
||||
onCompleted: () => {
|
||||
if (AuthManager.isAuthInitialized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AuthManager.setAuthRequired(false);
|
||||
AuthManager.setAuthInitialized(true);
|
||||
requestManager.processQueues();
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!data || AuthManager.isAuthInitialized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AuthManager.setAuthRequired(false);
|
||||
AuthManager.setAuthInitialized(true);
|
||||
requestManager.processQueues();
|
||||
}, [data]);
|
||||
|
||||
if (isAuthRequired === null) {
|
||||
return <SplashScreen />;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ export function Backup() {
|
||||
|
||||
const backupFileUrl = backupFileResponse.data?.createBackup.url;
|
||||
if (!backupFileUrl) {
|
||||
makeToast(t`Could not create backup`, 'error', getErrorMessage(backupFileResponse.errors));
|
||||
makeToast(t`Could not create backup`, 'error', getErrorMessage(backupFileResponse.error));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,9 +149,14 @@ export function Backup() {
|
||||
|
||||
const validateBackup = async (file: File) => {
|
||||
try {
|
||||
const {
|
||||
data: { validateBackup: validateBackupData },
|
||||
} = await requestManager.validateBackupFile(file, { fetchPolicy: 'network-only' }).response;
|
||||
const validateBackupResponse = await requestManager.validateBackupFile(file, {
|
||||
fetchPolicy: 'network-only',
|
||||
}).response;
|
||||
const validateBackupData = validateBackupResponse.data?.validateBackup;
|
||||
|
||||
if (!validateBackupData) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (validateBackupData.missingSources.length || validateBackupData.missingTrackers.length) {
|
||||
try {
|
||||
|
||||
@@ -110,6 +110,11 @@ const handleDownload = async (
|
||||
order: [{ by: ChapterOrderBy.SourceOrder, byType: SortOrder.Desc }],
|
||||
},
|
||||
).response;
|
||||
|
||||
if (!chapters.data) {
|
||||
return;
|
||||
}
|
||||
|
||||
const filteredChapters = filterChapters(chapters.data.chapters.nodes, meta);
|
||||
|
||||
const doNecessaryDownloadAheadDownloadsExist =
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { DocumentNode, MaybeMasked, Unmasked, useFragment } from '@apollo/client';
|
||||
import { DocumentNode, MaybeMasked, Unmasked } from '@apollo/client';
|
||||
import { useFragment } from '@apollo/client/react';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { makeToast } from '@/base/utils/Toast.ts';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
|
||||
@@ -49,6 +49,10 @@ const removeNonLibraryMangasFromCategories = async (): Promise<void> => {
|
||||
{ fetchPolicy: 'no-cache' },
|
||||
).response;
|
||||
|
||||
if (!nonLibraryMangas.data) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mangaIdsToRemove = Mangas.getIds(nonLibraryMangas.data.mangas.nodes);
|
||||
|
||||
if (mangaIdsToRemove.length) {
|
||||
|
||||
@@ -103,6 +103,10 @@ export const useManageMangaLibraryState = (
|
||||
makeToast(t`Could not load categories`, 'error', getErrorMessage(e));
|
||||
return;
|
||||
}
|
||||
if (!categories.data) {
|
||||
return;
|
||||
}
|
||||
|
||||
const userCreatedCategories = Categories.getUserCreated(categories.data.categories.nodes);
|
||||
|
||||
let duplicatedLibraryMangas:
|
||||
@@ -135,8 +139,8 @@ export const useManageMangaLibraryState = (
|
||||
);
|
||||
}
|
||||
|
||||
const doDuplicatesExist = duplicatedLibraryMangas?.data.mangas.totalCount;
|
||||
if (doDuplicatesExist) {
|
||||
const duplicateMangas = duplicatedLibraryMangas?.data?.mangas;
|
||||
if (duplicateMangas?.totalCount) {
|
||||
await Confirmation.show(
|
||||
{
|
||||
title: t`Are you sure?`,
|
||||
@@ -146,7 +150,7 @@ export const useManageMangaLibraryState = (
|
||||
show: true,
|
||||
title: t`Show entry`,
|
||||
contain: true,
|
||||
link: AppRoutes.manga.path(duplicatedLibraryMangas!.data.mangas.nodes[0].id),
|
||||
link: AppRoutes.manga.path(duplicateMangas.nodes[0].id),
|
||||
},
|
||||
confirm: {
|
||||
title: t`Add`,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import { useCallback, useState } from 'react';
|
||||
import { ApolloError } from '@apollo/client';
|
||||
import { CombinedGraphQLErrors } from '@apollo/client';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { baseCleanup } from '@/base/utils/Strings.ts';
|
||||
|
||||
@@ -23,7 +23,7 @@ export const useRefreshManga = (mangaId: string) => {
|
||||
requestManager.getMangaChaptersFetch(mangaId, { awaitRefetchQueries: true }).response,
|
||||
])
|
||||
.catch((e) => {
|
||||
if (e instanceof ApolloError && baseCleanup(e.message) === 'no chapters found') {
|
||||
if (CombinedGraphQLErrors.is(e) && baseCleanup(e.message) === 'no chapters found') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import Stack from '@mui/material/Stack';
|
||||
import Box from '@mui/material/Box';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { useLocation, useParams } from 'react-router-dom';
|
||||
import { isNetworkRequestInFlight } from '@apollo/client/core/networkStatus';
|
||||
import { isNetworkRequestInFlight } from '@apollo/client/utilities';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { CustomTooltip } from '@/base/components/CustomTooltip.tsx';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { DocumentNode, Unmasked } from '@apollo/client/core';
|
||||
import { DocumentNode, Unmasked } from '@apollo/client';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { i18n } from '@/i18n';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
@@ -197,7 +197,7 @@ export class Mangas {
|
||||
state: Pick<ChapterConditionInput, 'isRead' | 'isDownloaded' | 'isBookmarked'>,
|
||||
): Promise<GetMangasChapterIdsWithStateQuery['chapters']['nodes']> {
|
||||
const { data } = await requestManager.getMangasChapterIdsWithState(mangaIds, state).response;
|
||||
return data.chapters.nodes;
|
||||
return data?.chapters.nodes ?? [];
|
||||
}
|
||||
|
||||
static async downloadChapters(
|
||||
@@ -519,7 +519,7 @@ export class Mangas {
|
||||
getMetadataServerSettings(),
|
||||
]);
|
||||
|
||||
if (!mangaToMigrateData.manga || !mangaToMigrateToData?.fetchManga?.manga) {
|
||||
if (!mangaToMigrateData?.manga || !mangaToMigrateToData?.fetchManga?.manga) {
|
||||
throw new Error('Mangas::migrate: missing manga data');
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { ReadFieldFunction } from '@apollo/client/cache/core/types/common';
|
||||
import { FieldFunctionOptions } from '@apollo/client/cache';
|
||||
import { Reference } from '@apollo/client/utilities';
|
||||
import { MetaType } from '@/lib/graphql/generated/graphql.ts';
|
||||
|
||||
type ReadFieldFunction = FieldFunctionOptions['readField'];
|
||||
|
||||
export const updateMetadataList = (
|
||||
meta: MetaType[],
|
||||
existingMetas: Reference[] | undefined,
|
||||
|
||||
@@ -28,7 +28,10 @@ export const ImagesSettings = () => {
|
||||
|
||||
const clearCache = async () => {
|
||||
try {
|
||||
await Promise.all([triggerClearServerCache(), ImageCache.clearAll()]);
|
||||
await Promise.all([
|
||||
triggerClearServerCache({ variables: { input: { cachedPages: true, cachedThumbnails: true } } }),
|
||||
ImageCache.clearAll(),
|
||||
]);
|
||||
makeToast(t`Cleared the cache`, 'success');
|
||||
} catch (e) {
|
||||
makeToast(t`Could not clear the cache`, 'error', getErrorMessage(e));
|
||||
|
||||
@@ -51,6 +51,7 @@ export const getMetadataServerSettings = async (): Promise<MetadataServerSetting
|
||||
const { data, error } = await requestManager.getGlobalMeta().response;
|
||||
|
||||
if (error) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user