Handle duplicated chapters in chapter download action again

Regression 85cec6fd8d
This commit is contained in:
schroda
2025-07-13 14:21:30 +02:00
parent 73f8c72204
commit 89cff9db6a

View File

@@ -88,21 +88,26 @@ const handleDownload = async (
}, },
).response; ).response;
const filteredChapters = filterChapters(chapters.data.chapters.nodes, meta); const filteredChapters = filterChapters(chapters.data.chapters.nodes, meta);
const chaptersToDownload = filteredChapters const unreadUndownloadedChapters = filteredChapters.filter((chapter) => {
.filter((chapter) => { if (onlyUnread && chapter.isRead) {
if (onlyUnread && chapter.isRead) { return false;
return false; }
}
return !chapter.isDownloaded; return !chapter.isDownloaded;
}) });
.slice(-(size ?? 0));
if (!chaptersToDownload.length) { const uniqueChapters = Chapters.removeDuplicates(
unreadUndownloadedChapters.slice(-1)[0],
unreadUndownloadedChapters,
);
const chaptersToDownload = uniqueChapters.slice(-(size ?? 0));
const chaptersToDownloadWithDuplicates = Chapters.addDuplicates(chaptersToDownload, unreadUndownloadedChapters);
if (!chaptersToDownloadWithDuplicates.length) {
return; return;
} }
Chapters.performAction('download', Chapters.getIds(chaptersToDownload), {}).catch( Chapters.performAction('download', Chapters.getIds(chaptersToDownloadWithDuplicates), {}).catch(
defaultPromiseErrorHandler('ChaptersDownloadActionMenuItems::handleSelect::singleMangaMode'), defaultPromiseErrorHandler('ChaptersDownloadActionMenuItems::handleSelect::singleMangaMode'),
); );
}; };