From fd2946d1ae8fe88b92a5c2ceb92659c3b2433c79 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Tue, 23 Apr 2024 18:08:34 +0200 Subject: [PATCH] Mark duplicated chapters as read In case the "skip duplicated chapters" setting was enabled the duplicated chapters of the just read chapter did not get marked as read --- src/screens/Reader.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/screens/Reader.tsx b/src/screens/Reader.tsx index 4a03da47..9410ed33 100644 --- a/src/screens/Reader.tsx +++ b/src/screens/Reader.tsx @@ -186,16 +186,16 @@ export function Reader() { return; } - const getChapterIdToDelete = () => { + const getChapterIdsToDelete = () => { const isAutoDeletionEnabled = !!patch.isRead && !!metadataSettings.deleteChaptersWhileReading; if (!isAutoDeletionEnabled || !mangaChapters) { - return -1; + return []; } const chapterToDelete = [chapter, ...prevChapters][metadataSettings.deleteChaptersWhileReading - 1]; if (!chapterToDelete) { - return -1; + return []; } // chapter has to exist in the cache since the reader fetches all chapters of the manga @@ -205,10 +205,14 @@ export function Reader() { chapterToDeleteUpToDateData.isRead && Chapters.isDeletable(chapterToDeleteUpToDateData, metadataSettings.deleteChaptersWithBookmark); if (!shouldDeleteChapter) { - return -1; + return []; } - return chapterToDelete.id; + if (!settings.skipDupChapters) { + return Chapters.getIds([chapterToDelete]); + } + + return Chapters.getIds(Chapters.addDuplicates([chapterToDelete], mangaChapters)); }; const downloadAhead = () => { @@ -241,7 +245,7 @@ export function Reader() { return; } - Chapters.download(chapterIdsToDownload!).catch( + Chapters.download(chapterIdsToDownload).catch( defaultPromiseErrorHandler('Reader::updateChapter: shouldDownloadAhead'), ); } @@ -250,9 +254,9 @@ export function Reader() { downloadAhead(); requestManager - .updateChapter(chapter.id, { + .updateChapters([chapter.id], { ...patch, - chapterIdToDelete: getChapterIdToDelete(), + chapterIdsToDelete: getChapterIdsToDelete(), trackProgressMangaId: metadataSettings.updateProgressAfterReading && patch.isRead && manga.trackRecords.totalCount ? manga.id