From c81189a9ed35c1144466aa15fea0fcd14f5f464a Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 12 Apr 2023 18:37:23 +0200 Subject: [PATCH] Fix/chapter mark as unread not resetting last page read (#282) * [ChapterCard] Reset last page read to first page when changing chapters read status The last page read was set to the second page instead of the first one * [ChapterList] Reset last page read to first page when changing chapters read status The "ChapterCard" and the "FAB" didn't have the same behaviour when marking a chapter as unread. The "ChapterCard" also reset the last read page while the FAB only changed the read status. --- src/components/manga/ChapterCard.tsx | 2 +- src/components/manga/ChapterList.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/manga/ChapterCard.tsx b/src/components/manga/ChapterCard.tsx index 125be776..d644a7bf 100644 --- a/src/components/manga/ChapterCard.tsx +++ b/src/components/manga/ChapterCard.tsx @@ -68,7 +68,7 @@ const ChapterCard: React.FC = (props: IProps) => { const formData = new FormData(); formData.append(key, value); if (key === 'read') { - formData.append('lastPageRead', '1'); + formData.append('lastPageRead', '0'); } client .patch(`/api/v1/manga/${chapter.mangaId}/chapter/${chapter.index}`, formData) diff --git a/src/components/manga/ChapterList.tsx b/src/components/manga/ChapterList.tsx index 6e9e2e58..96ae7dea 100644 --- a/src/components/manga/ChapterList.tsx +++ b/src/components/manga/ChapterList.tsx @@ -162,8 +162,10 @@ const ChapterList: React.FC = ({ mangaId }) => { if (action === 'delete') change.delete = true; else if (action === 'bookmark') change.isBookmarked = true; else if (action === 'unbookmark') change.isBookmarked = false; - else if (action === 'mark_as_read') change.isRead = true; - else if (action === 'mark_as_unread') change.isRead = false; + else if (action === 'mark_as_read' || action === 'mark_as_unread') { + change.isRead = action === 'mark_as_read'; + change.lastPageRead = 0; + } actionPromise = client.post('/api/v1/chapter/batch', { chapterIds, change }); }