mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 06:42:07 +01:00
Remove unnecessary "downloadNewChapters" call in "fetchChapters" mutation (#652)
Gets already called by "Chapter::fetchChapterList", thus, this is unnecessary. Additionally, "chapters.toList()" and "chapters.map()" have to be called in a transaction block, which they are not, and thus, cause an unhandled exception, breaking the mutation
This commit is contained in:
@@ -121,21 +121,17 @@ class ChapterMutation {
|
|||||||
val (clientMutationId, mangaId) = input
|
val (clientMutationId, mangaId) = input
|
||||||
|
|
||||||
return future {
|
return future {
|
||||||
val numberOfCurrentChapters = Chapter.getCountOfMangaChapters(mangaId)
|
|
||||||
Chapter.fetchChapterList(mangaId)
|
Chapter.fetchChapterList(mangaId)
|
||||||
numberOfCurrentChapters
|
}.thenApply {
|
||||||
}.thenApply { numberOfCurrentChapters ->
|
|
||||||
val chapters = transaction {
|
val chapters = transaction {
|
||||||
ChapterTable.select { ChapterTable.manga eq mangaId }
|
ChapterTable.select { ChapterTable.manga eq mangaId }
|
||||||
.orderBy(ChapterTable.sourceOrder)
|
.orderBy(ChapterTable.sourceOrder)
|
||||||
|
.map { ChapterType(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// download new chapters if settings flag is enabled
|
|
||||||
Chapter.downloadNewChapters(mangaId, numberOfCurrentChapters, chapters.toList())
|
|
||||||
|
|
||||||
FetchChaptersPayload(
|
FetchChaptersPayload(
|
||||||
clientMutationId = clientMutationId,
|
clientMutationId = clientMutationId,
|
||||||
chapters = chapters.map { ChapterType(it) }
|
chapters = chapters
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ object Chapter {
|
|||||||
return chapterList
|
return chapterList
|
||||||
}
|
}
|
||||||
|
|
||||||
fun downloadNewChapters(mangaId: Int, prevNumberOfChapters: Int, newChapters: List<ResultRow>) {
|
private fun downloadNewChapters(mangaId: Int, prevNumberOfChapters: Int, newChapters: List<ResultRow>) {
|
||||||
// convert numbers to be index based
|
// convert numbers to be index based
|
||||||
val currentNumberOfChapters = (prevNumberOfChapters - 1).coerceAtLeast(0)
|
val currentNumberOfChapters = (prevNumberOfChapters - 1).coerceAtLeast(0)
|
||||||
val updatedNumberOfChapters = (newChapters.size - 1).coerceAtLeast(0)
|
val updatedNumberOfChapters = (newChapters.size - 1).coerceAtLeast(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user