From ee03c56684aafb60e82b835c9d11f7a9671daaf8 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Tue, 5 Dec 2023 22:18:53 +0100 Subject: [PATCH] Fix/mark previous as read action includes the selected chapter (#483) * Exclude the current chapter in the "mark prev as read" action * Prevent unnecessary request for first chapter In case "mark prev as read" gets called for the first chapter, the is no chapter to mark as read, thus, no request has to be sent --- src/components/manga/ChapterCard.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/manga/ChapterCard.tsx b/src/components/manga/ChapterCard.tsx index 316d04a8..3847f690 100644 --- a/src/components/manga/ChapterCard.tsx +++ b/src/components/manga/ChapterCard.tsx @@ -83,9 +83,15 @@ export const ChapterCard: React.FC = (props: IProps) => { if (key === 'markPrevRead') { const index = allChapters.findIndex(({ id: chapterId }) => chapterId === chapter.id); + + const isFirstChapter = index + 1 > allChapters.length - 1; + if (isFirstChapter) { + return; + } + requestManager.updateChapters( allChapters - .slice(index) + .slice(index + 1) .filter(({ isRead }) => !isRead) .map(({ id: chapterId }) => chapterId), { isRead: true, chapterIdsToDelete },