Prevent duplicated downloads in download queue
The mutation to add chapters to the download queue returns the current download queue. Thus, the local queue already includes the new downloads and adding them blindly in the download subscription will cause them to be in the local queue twice.
This commit is contained in:
@@ -2981,7 +2981,16 @@ export class RequestManager {
|
||||
return data;
|
||||
}
|
||||
|
||||
const queueWithAddedDownloads = [...data.downloadStatus.queue, ...downloadsToAdd];
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user