Improve reader chapter update on last page reached
In case "endReached" is force set to "true" the chapters last page index should always be set to prevent 2 chapter updates - 1. for second to last page, read true - 2. last page, read true This only happens in "continuous pagers" which have to handle cases where the end of the last page is already visible while the last page itself is too small to ever get set as the "current page index"
This commit is contained in:
@@ -389,8 +389,10 @@ export class ReaderControls {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasLastPageReadChanged = pageIndex !== currentChapterUpToDate.lastPageRead;
|
const actualPageIndex = endReached ? currentChapterUpToDate.pageCount - 1 : pageIndex;
|
||||||
const isLastPage = pageIndex === currentChapterUpToDate.pageCount - 1;
|
|
||||||
|
const hasLastPageReadChanged = actualPageIndex !== currentChapterUpToDate.lastPageRead;
|
||||||
|
const isLastPage = actualPageIndex === currentChapterUpToDate.pageCount - 1;
|
||||||
const hasIsReadChanged = (isLastPage || endReached) && !currentChapterUpToDate.isRead;
|
const hasIsReadChanged = (isLastPage || endReached) && !currentChapterUpToDate.isRead;
|
||||||
|
|
||||||
const shouldUpdateChapter = hasLastPageReadChanged || hasIsReadChanged;
|
const shouldUpdateChapter = hasLastPageReadChanged || hasIsReadChanged;
|
||||||
@@ -399,7 +401,7 @@ export class ReaderControls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateChapter({
|
updateChapter({
|
||||||
lastPageRead: hasLastPageReadChanged ? pageIndex : undefined,
|
lastPageRead: hasLastPageReadChanged ? actualPageIndex : undefined,
|
||||||
isRead: isLastPage ? true : undefined,
|
isRead: isLastPage ? true : undefined,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user