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:
Chance Zibolski
2024-01-20 16:41:47 -08:00
committed by GitHub
parent f224918f33
commit 57d5bc6480
10 changed files with 114 additions and 26 deletions

View File

@@ -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()