@@ -9,6 +9,7 @@
|
|||||||
import type {
|
import type {
|
||||||
ApolloClient,
|
ApolloClient,
|
||||||
DocumentNode,
|
DocumentNode,
|
||||||
|
InMemoryCache,
|
||||||
MaybeMasked,
|
MaybeMasked,
|
||||||
OperationVariables,
|
OperationVariables,
|
||||||
TypedDocumentNode,
|
TypedDocumentNode,
|
||||||
@@ -217,6 +218,7 @@ import {
|
|||||||
DownloaderState,
|
DownloaderState,
|
||||||
DownloadUpdateType,
|
DownloadUpdateType,
|
||||||
FetchSourceMangaType,
|
FetchSourceMangaType,
|
||||||
|
MangaJobStatus,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
} from '@/lib/graphql/generated/graphql-base.types.ts';
|
} from '@/lib/graphql/generated/graphql-base.types.ts';
|
||||||
import { GET_GLOBAL_METADATAS } from '@/lib/graphql/metadata/GlobalMetadataQuery.ts';
|
import { GET_GLOBAL_METADATAS } from '@/lib/graphql/metadata/GlobalMetadataQuery.ts';
|
||||||
@@ -269,7 +271,12 @@ import {
|
|||||||
START_DOWNLOADER,
|
START_DOWNLOADER,
|
||||||
STOP_DOWNLOADER,
|
STOP_DOWNLOADER,
|
||||||
} from '@/lib/graphql/download/DownloaderMutation.ts';
|
} from '@/lib/graphql/download/DownloaderMutation.ts';
|
||||||
import { GET_CHAPTERS_HISTORY, GET_CHAPTERS_MANGA, GET_CHAPTERS_UPDATES } from '@/lib/graphql/chapter/ChapterQuery.ts';
|
import {
|
||||||
|
GET_CHAPTERS_HISTORY,
|
||||||
|
GET_CHAPTERS_MANGA,
|
||||||
|
GET_CHAPTERS_READER,
|
||||||
|
GET_CHAPTERS_UPDATES,
|
||||||
|
} from '@/lib/graphql/chapter/ChapterQuery.ts';
|
||||||
import {
|
import {
|
||||||
GET_CHAPTER_PAGES_FETCH,
|
GET_CHAPTER_PAGES_FETCH,
|
||||||
GET_MANGA_CHAPTERS_FETCH,
|
GET_MANGA_CHAPTERS_FETCH,
|
||||||
@@ -328,6 +335,7 @@ import { KO_SYNC_LOGIN, KO_SYNC_LOGOUT } from '@/lib/graphql/koreader/KoreaderSy
|
|||||||
import { GET_KO_SYNC_STATUS } from '@/lib/graphql/koreader/KoreaderSyncQuery.ts';
|
import { GET_KO_SYNC_STATUS } from '@/lib/graphql/koreader/KoreaderSyncQuery.ts';
|
||||||
import { ImageCache } from '@/lib/service-worker/ImageCache.ts';
|
import { ImageCache } from '@/lib/service-worker/ImageCache.ts';
|
||||||
import { Sources } from '@/features/source/services/Sources.ts';
|
import { Sources } from '@/features/source/services/Sources.ts';
|
||||||
|
import uniqBy from 'lodash/fp/uniqBy';
|
||||||
|
|
||||||
enum GQLMethod {
|
enum GQLMethod {
|
||||||
QUERY = 'QUERY',
|
QUERY = 'QUERY',
|
||||||
@@ -2220,7 +2228,7 @@ export class RequestManager {
|
|||||||
{
|
{
|
||||||
id: Number(mangaId),
|
id: Number(mangaId),
|
||||||
},
|
},
|
||||||
{ refetchQueries: [GET_CHAPTERS_MANGA], errorPolicy: 'all', ...options },
|
{ refetchQueries: [GET_CHAPTERS_MANGA, GET_CHAPTERS_READER], errorPolicy: 'all', ...options },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3327,6 +3335,18 @@ export class RequestManager {
|
|||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
this.graphQLClient.client.refetchQueries({
|
||||||
|
updateCache(cache) {
|
||||||
|
uniqBy('mangaId', result.data?.chapters.nodes).forEach((chapter) => {
|
||||||
|
Object.keys((cache as InMemoryCache).extract().ROOT_QUERY as object)
|
||||||
|
.filter((key) => key.includes('chapters') && key.includes(`mangaId":${chapter.mangaId}`))
|
||||||
|
.forEach((key) => cache.evict({ fieldName: key }));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, [result]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
fetchMore: (...args: Parameters<(typeof result)['fetchMore']>) => {
|
fetchMore: (...args: Parameters<(typeof result)['fetchMore']>) => {
|
||||||
@@ -3515,12 +3535,22 @@ export class RequestManager {
|
|||||||
onData: (onDataOptions) => {
|
onData: (onDataOptions) => {
|
||||||
const updatesChanged = onDataOptions.data.data?.libraryUpdateStatusChanged;
|
const updatesChanged = onDataOptions.data.data?.libraryUpdateStatusChanged;
|
||||||
|
|
||||||
|
const cache = this.graphQLClient.client.cache as InMemoryCache;
|
||||||
|
|
||||||
if (!updatesChanged?.omittedUpdates) {
|
if (!updatesChanged?.omittedUpdates) {
|
||||||
|
updatesChanged?.mangaUpdates
|
||||||
|
.filter((update) => update.status === MangaJobStatus.Complete)
|
||||||
|
.forEach((update) =>
|
||||||
|
Object.keys(cache.extract().ROOT_QUERY as object)
|
||||||
|
.filter(
|
||||||
|
(key) =>
|
||||||
|
key.includes('chapters') && key.includes(`mangaId":${update.manga.id}`),
|
||||||
|
)
|
||||||
|
.forEach((key) => cache.evict({ fieldName: key })),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { cache } = this.graphQLClient.client;
|
|
||||||
|
|
||||||
cache.gc();
|
cache.gc();
|
||||||
cache.evict({ broadcast: true, id: 'LibraryUpdateStatus' });
|
cache.evict({ broadcast: true, id: 'LibraryUpdateStatus' });
|
||||||
cache.evict({ broadcast: true, fieldName: 'libraryUpdateStatus' });
|
cache.evict({ broadcast: true, fieldName: 'libraryUpdateStatus' });
|
||||||
|
|||||||
Reference in New Issue
Block a user