mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 03:14:40 -05:00
Add support for configuring which categories are downloaded automatically (#832)
* Rename IncludeInUpdate class to IncludeOrExclude Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com> * Add support for configuring which categories are downloaded automatically If a manga has no configured categories, behavior remains the same and the automatic download functionality will download new chapters without consulting the category includeInDownload configuration. Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com> --------- Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
This commit is contained in:
@@ -19,7 +19,7 @@ import suwayomi.tachidesk.manga.impl.Category
|
||||
import suwayomi.tachidesk.manga.impl.Category.DEFAULT_CATEGORY_ID
|
||||
import suwayomi.tachidesk.manga.impl.util.lang.isEmpty
|
||||
import suwayomi.tachidesk.manga.impl.util.lang.isNotEmpty
|
||||
import suwayomi.tachidesk.manga.model.dataclass.IncludeInUpdate
|
||||
import suwayomi.tachidesk.manga.model.dataclass.IncludeOrExclude
|
||||
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
|
||||
import suwayomi.tachidesk.manga.model.table.CategoryMetaTable
|
||||
import suwayomi.tachidesk.manga.model.table.CategoryTable
|
||||
@@ -85,7 +85,8 @@ class CategoryMutation {
|
||||
data class UpdateCategoryPatch(
|
||||
val name: String? = null,
|
||||
val default: Boolean? = null,
|
||||
val includeInUpdate: IncludeInUpdate? = null,
|
||||
val includeInUpdate: IncludeOrExclude? = null,
|
||||
val includeInDownload: IncludeOrExclude? = null,
|
||||
)
|
||||
|
||||
data class UpdateCategoryPayload(
|
||||
@@ -136,6 +137,13 @@ class CategoryMutation {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (patch.includeInDownload != null) {
|
||||
CategoryTable.update({ CategoryTable.id inList ids }) { update ->
|
||||
patch.includeInDownload.also {
|
||||
update[includeInDownload] = it.value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +237,8 @@ class CategoryMutation {
|
||||
val name: String,
|
||||
val order: Int? = null,
|
||||
val default: Boolean? = null,
|
||||
val includeInUpdate: IncludeInUpdate? = null,
|
||||
val includeInUpdate: IncludeOrExclude? = null,
|
||||
val includeInDownload: IncludeOrExclude? = null,
|
||||
)
|
||||
|
||||
data class CreateCategoryPayload(
|
||||
@@ -238,7 +247,7 @@ class CategoryMutation {
|
||||
)
|
||||
|
||||
fun createCategory(input: CreateCategoryInput): CreateCategoryPayload {
|
||||
val (clientMutationId, name, order, default, includeInUpdate) = input
|
||||
val (clientMutationId, name, order, default, includeInUpdate, includeInDownload) = input
|
||||
transaction {
|
||||
require(CategoryTable.select { CategoryTable.name eq input.name }.isEmpty()) {
|
||||
"'name' must be unique"
|
||||
@@ -271,6 +280,9 @@ class CategoryMutation {
|
||||
if (includeInUpdate != null) {
|
||||
it[CategoryTable.includeInUpdate] = includeInUpdate.value
|
||||
}
|
||||
if (includeInDownload != null) {
|
||||
it[CategoryTable.includeInDownload] = includeInDownload.value
|
||||
}
|
||||
}
|
||||
|
||||
Category.normalizeCategories()
|
||||
|
||||
@@ -15,7 +15,7 @@ import suwayomi.tachidesk.graphql.server.primitives.Edge
|
||||
import suwayomi.tachidesk.graphql.server.primitives.Node
|
||||
import suwayomi.tachidesk.graphql.server.primitives.NodeList
|
||||
import suwayomi.tachidesk.graphql.server.primitives.PageInfo
|
||||
import suwayomi.tachidesk.manga.model.dataclass.IncludeInUpdate
|
||||
import suwayomi.tachidesk.manga.model.dataclass.IncludeOrExclude
|
||||
import suwayomi.tachidesk.manga.model.table.CategoryTable
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
@@ -24,14 +24,16 @@ class CategoryType(
|
||||
val order: Int,
|
||||
val name: String,
|
||||
val default: Boolean,
|
||||
val includeInUpdate: IncludeInUpdate,
|
||||
val includeInUpdate: IncludeOrExclude,
|
||||
val includeInDownload: IncludeOrExclude,
|
||||
) : Node {
|
||||
constructor(row: ResultRow) : this(
|
||||
row[CategoryTable.id].value,
|
||||
row[CategoryTable.order],
|
||||
row[CategoryTable.name],
|
||||
row[CategoryTable.isDefault],
|
||||
IncludeInUpdate.fromValue(row[CategoryTable.includeInUpdate]),
|
||||
IncludeOrExclude.fromValue(row[CategoryTable.includeInUpdate]),
|
||||
IncludeOrExclude.fromValue(row[CategoryTable.includeInDownload]),
|
||||
)
|
||||
|
||||
fun mangas(dataFetchingEnvironment: DataFetchingEnvironment): CompletableFuture<MangaNodeList> {
|
||||
|
||||
Reference in New Issue
Block a user