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:
schroda
2025-01-16 13:22:13 +01:00
parent ef08799fc0
commit a96bc2c1da
2 changed files with 22 additions and 30 deletions

View File

@@ -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,
});
};