mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 11:24:35 -05:00
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:
@@ -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) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user