From e25aa98365c882ee7ac22529144d9432523ed191 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:47:16 +0100 Subject: [PATCH] Do not update "download status" on "download updates" For large download queues this makes the app unusable. At the moment this is not needed anyway and once it is, it needs to be improved and only be done in the "download queue" page since the queue is only use there --- src/lib/requests/RequestManager.ts | 68 ------------------------------ 1 file changed, 68 deletions(-) diff --git a/src/lib/requests/RequestManager.ts b/src/lib/requests/RequestManager.ts index e7962a65..348150c7 100644 --- a/src/lib/requests/RequestManager.ts +++ b/src/lib/requests/RequestManager.ts @@ -2954,74 +2954,6 @@ export class RequestManager { }), }); }); - - const downloadsToRemove = - downloadChanged?.updates - .filter((update) => - [ - DownloadUpdateType.Dequeued, - DownloadUpdateType.Finished, - DownloadUpdateType.Position, - ].includes(update.type), - ) - .map((update) => update.download.chapter.id) ?? []; - const downloadsToAdd = - downloadChanged?.updates - .filter((update) => update.type === DownloadUpdateType.Queued) - .map((update) => update.download) ?? []; - const downloadsToReorder = - downloadChanged?.updates - .filter((update) => update.type === DownloadUpdateType.Position) - .map((update) => update.download) ?? []; - - cache.updateQuery( - { - query: GET_DOWNLOAD_STATUS, - variables: {}, - }, - (data) => { - if (!data) { - return data; - } - - const downloadsToAddWithoutAlreadyKnown = downloadsToAdd.filter((download) => - data.downloadStatus.queue.every( - (queueDownload) => queueDownload.chapter.id !== download.chapter.id, - ), - ); - - const queueWithAddedDownloads = [ - ...data.downloadStatus.queue, - ...downloadsToAddWithoutAlreadyKnown, - ]; - const queueWithoutRemovedDownloads = !downloadsToRemove.length - ? queueWithAddedDownloads - : queueWithAddedDownloads.filter( - (download) => !downloadsToRemove.includes(download.chapter.id), - ); - - const queueWithReorderedDownloads = !downloadsToReorder.length - ? queueWithoutRemovedDownloads - : (() => { - const tmpQueue = [...queueWithoutRemovedDownloads]; - - downloadsToReorder.forEach((download) => { - tmpQueue.splice(download.position, 0, download); - }); - - return tmpQueue; - })(); - - return { - ...data, - downloadStatus: { - ...data.downloadStatus, - state: downloadChanged?.state ?? data.downloadStatus.state, - queue: queueWithReorderedDownloads, - }, - }; - }, - ); }, }, );