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:
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user