Delete chapter when read even if already marked as read
ReaderControls#useUpdateCurrentPageIndex: On a page change the chapter update needs to be always queued since the deletion of downloaded chapters while reading logic is in the "ReaderService#updateChapter" function. Thus, when the update is prevented here, this logic would never get triggered. ReaderService#useUpdateChapter: In case the read status or lastPageRead of a chapter did not change, the update was not triggered. However, there might still be chapter downloads that need to be de deleted, which was never handled in such a case.
This commit is contained in:
@@ -441,18 +441,10 @@ export class ReaderControls {
|
||||
}
|
||||
|
||||
const actualPageIndex = endReached ? currentChapterUpToDate.pageCount - 1 : pageIndex;
|
||||
|
||||
const hasLastPageReadChanged = actualPageIndex !== currentChapterUpToDate.lastPageRead;
|
||||
const isLastPage = actualPageIndex === currentChapterUpToDate.pageCount - 1;
|
||||
const hasIsReadChanged = (isLastPage || endReached) && !currentChapterUpToDate.isRead;
|
||||
|
||||
const shouldUpdateChapter = hasLastPageReadChanged || hasIsReadChanged;
|
||||
if (!shouldUpdateChapter) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateChapter({
|
||||
lastPageRead: hasLastPageReadChanged ? actualPageIndex : undefined,
|
||||
lastPageRead: actualPageIndex,
|
||||
isRead: isLastPage ? true : undefined,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user