diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt index b40b132b..5c809293 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt @@ -85,7 +85,7 @@ class ChapterMutation { this[ChapterTable.isBookmarked] = it } patch.lastPageRead?.also { - this[ChapterTable.lastPageRead] = it.coerceIn(0, chapterIdToPageCount[chapterId]) + this[ChapterTable.lastPageRead] = it.coerceAtMost(chapterIdToPageCount[chapterId] ?: 0).coerceAtLeast(0) this[ChapterTable.lastReadAt] = now } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt index 36e7c41f..e6616466 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt @@ -159,7 +159,7 @@ private class ChapterForDownload( ChapterTable.update({ ChapterTable.id eq chapterId }) { val pageCount = pageList.size it[ChapterTable.pageCount] = pageCount - it[ChapterTable.lastPageRead] = chapterEntry[ChapterTable.lastPageRead].coerceIn(0, pageCount - 1) + it[ChapterTable.lastPageRead] = chapterEntry[ChapterTable.lastPageRead].coerceAtMost(pageCount - 1).coerceAtLeast(0) } } }