Reduce chapter update mutation requests
This commit is contained in:
@@ -316,15 +316,17 @@ export class ReaderControls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const hasLastPageReadChanged = pageIndex !== currentChapterUpToDate.lastPageRead;
|
const hasLastPageReadChanged = pageIndex !== currentChapterUpToDate.lastPageRead;
|
||||||
const isLasPage = endReached || pageIndex === currentChapterUpToDate.pageCount - 1;
|
const isLastPage = pageIndex === currentChapterUpToDate.pageCount - 1;
|
||||||
const shouldUpdateChapter = hasLastPageReadChanged || isLasPage;
|
const hasIsReadChanged = (isLastPage || endReached) && !currentChapterUpToDate.isRead;
|
||||||
|
|
||||||
|
const shouldUpdateChapter = hasLastPageReadChanged || hasIsReadChanged;
|
||||||
if (!shouldUpdateChapter) {
|
if (!shouldUpdateChapter) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateChapter({
|
updateChapter({
|
||||||
lastPageRead: hasLastPageReadChanged ? pageIndex : undefined,
|
lastPageRead: hasLastPageReadChanged ? pageIndex : undefined,
|
||||||
isRead: isLasPage ? true : undefined,
|
isRead: isLastPage ? true : undefined,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user