Feature/automatically download new chapters (#596)

* Automatically download new chapters

* Log queued downloads

* Add function to get number of manga chapters
This commit is contained in:
schroda
2023-07-20 23:47:46 +02:00
committed by GitHub
parent c1d702a51c
commit 8690e918dd
6 changed files with 59 additions and 5 deletions

View File

@@ -122,17 +122,21 @@ class ChapterMutation {
val (clientMutationId, mangaId) = input
return future {
val numberOfCurrentChapters = Chapter.getCountOfMangaChapters(mangaId)
Chapter.fetchChapterList(mangaId)
}.thenApply {
numberOfCurrentChapters
}.thenApply { numberOfCurrentChapters ->
val chapters = transaction {
ChapterTable.select { ChapterTable.manga eq mangaId }
.orderBy(ChapterTable.sourceOrder)
.map { ChapterType(it) }
}
// download new chapters if settings flag is enabled
Chapter.downloadNewChapters(mangaId, numberOfCurrentChapters, chapters.toList())
FetchChaptersPayload(
clientMutationId = clientMutationId,
chapters = chapters
chapters = chapters.map { ChapterType(it) }
)
}
}