Reduce chapter update mutation requests

This commit is contained in:
schroda
2024-12-10 02:12:38 +01:00
parent 6039d5b78e
commit 5cda9a3972

View File

@@ -316,15 +316,17 @@ export class ReaderControls {
}
const hasLastPageReadChanged = pageIndex !== currentChapterUpToDate.lastPageRead;
const isLasPage = endReached || pageIndex === currentChapterUpToDate.pageCount - 1;
const shouldUpdateChapter = hasLastPageReadChanged || isLasPage;
const isLastPage = pageIndex === currentChapterUpToDate.pageCount - 1;
const hasIsReadChanged = (isLastPage || endReached) && !currentChapterUpToDate.isRead;
const shouldUpdateChapter = hasLastPageReadChanged || hasIsReadChanged;
if (!shouldUpdateChapter) {
return;
}
updateChapter({
lastPageRead: hasLastPageReadChanged ? pageIndex : undefined,
isRead: isLasPage ? true : undefined,
isRead: isLastPage ? true : undefined,
});
};