From 8783956fbc2cedfce1d43111367eb146b5d2d7d8 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Tue, 8 Jul 2025 22:07:17 +0200 Subject: [PATCH] Slice chapter list correctly for downloads Chapters are sorted in desc order and thus, the oldest chapters are at the end of the list. Thus, the chapters to download need to be taken from the end instead from the start --- .../components/actions/ChaptersDownloadActionMenuItems.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/chapter/components/actions/ChaptersDownloadActionMenuItems.tsx b/src/modules/chapter/components/actions/ChaptersDownloadActionMenuItems.tsx index f9475a3c..ff8fd0b0 100644 --- a/src/modules/chapter/components/actions/ChaptersDownloadActionMenuItems.tsx +++ b/src/modules/chapter/components/actions/ChaptersDownloadActionMenuItems.tsx @@ -82,11 +82,11 @@ const handleDownload = async ( const chapters = await requestManager.getChapters( GET_CHAPTERS_MANGA, { + // Align conditions/filters with the query from ChapterList to potentially be able to reuse the cache condition: { mangaId: Number(mangaId) }, order: [{ by: ChapterOrderBy.SourceOrder, byType: SortOrder.Desc }], }, ).response; - const filteredChapters = filterChapters(chapters.data.chapters.nodes, meta); const chaptersToDownload = filteredChapters .filter((chapter) => { @@ -96,7 +96,7 @@ const handleDownload = async ( return !chapter.isDownloaded; }) - .slice(0, size); + .slice(-(size ?? 0)); if (!chaptersToDownload.length) { return;