From 10a77722ccfd6afe15985db59715244916ec60ed Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:42:22 +0100 Subject: [PATCH] Remove outdated "download types" from apollo cache --- src/lib/requests/RequestManager.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lib/requests/RequestManager.ts b/src/lib/requests/RequestManager.ts index 1e1ded18..e7962a65 100644 --- a/src/lib/requests/RequestManager.ts +++ b/src/lib/requests/RequestManager.ts @@ -2931,11 +2931,30 @@ export class RequestManager { const { cache } = this.graphQLClient.client; if (downloadChanged?.omittedUpdates) { - cache.evict({ broadcast: true, fieldName: 'downloadStatus' }); + cache.gc(); cache.evict({ broadcast: true, id: 'DownloadStatus:{}' }); + cache.evict({ broadcast: true, fieldName: 'downloadStatus' }); 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 = downloadChanged?.updates .filter((update) =>