Add fetch chapter pages (#576)

This commit is contained in:
Mitchell Syer
2023-06-10 14:12:42 -04:00
committed by GitHub
parent b59af683ac
commit 812eb8001b
2 changed files with 62 additions and 6 deletions

View File

@@ -83,8 +83,6 @@ private class ChapterForDownload(
private fun updateDatabasePages(pageList: List<Page>) {
val chapterId = chapterEntry[ChapterTable.id].value
val chapterIndex = chapterEntry[ChapterTable.sourceOrder]
val mangaId = chapterEntry[ChapterTable.manga].value
transaction {
pageList.forEach { page ->
@@ -108,7 +106,7 @@ private class ChapterForDownload(
}
}
updatePageCount(pageList, mangaId, chapterIndex)
updatePageCount(pageList, chapterId)
// chapter was updated
chapterEntry = freshChapterEntry()
@@ -116,13 +114,12 @@ private class ChapterForDownload(
private fun updatePageCount(
pageList: List<Page>,
mangaId: Int,
chapterIndex: Int
chapterId: Int
) {
val pageCount = pageList.count()
transaction {
ChapterTable.update({ (ChapterTable.manga eq mangaId) and (ChapterTable.sourceOrder eq chapterIndex) }) {
ChapterTable.update({ ChapterTable.id eq chapterId }) {
it[ChapterTable.pageCount] = pageCount
}
}