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
This commit is contained in:
schroda
2023-12-05 22:18:53 +01:00
committed by GitHub
parent b2e6c040f1
commit ee03c56684

View File

@@ -83,9 +83,15 @@ export const ChapterCard: React.FC<IProps> = (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 },