Remove outdated "download types" from apollo cache

This commit is contained in:
schroda
2025-01-12 16:42:22 +01:00
parent 77973df0ff
commit 10a77722cc

View File

@@ -2931,11 +2931,30 @@ export class RequestManager {
const { cache } = this.graphQLClient.client; const { cache } = this.graphQLClient.client;
if (downloadChanged?.omittedUpdates) { if (downloadChanged?.omittedUpdates) {
cache.evict({ broadcast: true, fieldName: 'downloadStatus' }); cache.gc();
cache.evict({ broadcast: true, id: 'DownloadStatus:{}' }); cache.evict({ broadcast: true, id: 'DownloadStatus:{}' });
cache.evict({ broadcast: true, fieldName: 'downloadStatus' });
return; return;
} }
downloadChanged?.updates.forEach((update) => {
if (![DownloadUpdateType.Dequeued, DownloadUpdateType.Finished].includes(update.type)) {
return;
}
cache.evict({
id: cache.identify({
__typename: 'DownloadType',
chapter: {
__ref: cache.identify({
__typename: 'ChapterType',
id: update.download.chapter.id,
}),
},
}),
});
});
const downloadsToRemove = const downloadsToRemove =
downloadChanged?.updates downloadChanged?.updates
.filter((update) => .filter((update) =>