Fix/server config duplicated types (#1672)

* Move "serverConfig" to "server-config" module

* Remove duplicated types

Unintentionally introduced with 8ef2877040
This commit is contained in:
schroda
2025-09-29 17:24:26 +02:00
committed by GitHub
parent 5c79672d84
commit 9062252939
8 changed files with 34 additions and 93 deletions

View File

@@ -4,6 +4,12 @@ plugins {
.get()
.pluginId,
)
id(
libs.plugins.kotlin.serialization
.get()
.pluginId,
)
}
dependencies {

View File

@@ -1,5 +1,7 @@
package suwayomi.tachidesk.graphql.types
import suwayomi.tachidesk.server.serverConfig
enum class WebUIInterface {
BROWSER,
ELECTRON,
@@ -30,17 +32,30 @@ enum class WebUIFlavor(
"https://api.github.com/repos/Suwayomi/Suwayomi-WebUI-preview/releases/latest",
"Suwayomi-WebUI",
),
VUI(
"VUI",
"https://github.com/Suwayomi/Suwayomi-VUI",
"https://raw.githubusercontent.com/Suwayomi/Suwayomi-VUI/master/versionToServerVersionMapping.json",
"https://raw.githubusercontent.com/Suwayomi/Suwayomi-VUI/main/versionToServerVersionMapping.json",
"https://api.github.com/repos/Suwayomi/Suwayomi-VUI/releases/latest",
"Suwayomi-VUI",
"Suwayomi-VUI-Web",
),
CUSTOM(
"Custom",
"repoURL",
"versionMappingUrl",
"latestReleaseInfoURL",
"baseFileName",
),
CUSTOM("Custom", "", "", "", ""),
;
companion object {
fun from(flavor: String): WebUIFlavor = entries.find { it.name.lowercase() == flavor.lowercase() } ?: WEBUI
val default: WebUIFlavor = WEBUI
fun from(value: String): WebUIFlavor = entries.find { it.uiName == value } ?: default
val current: WebUIFlavor
get() = serverConfig.webUIFlavor.value
}
}

View File

@@ -1,9 +1,7 @@
package suwayomi.tachidesk.manga.impl.extension
object ExtensionsList {
val repoMatchRegex =
(
"https:\\/\\/(?>www\\.|raw\\.)?(github|githubusercontent)\\.com" +
"\\/([^\\/]+)\\/([^\\/]+)(?>(?>\\/tree|\\/blob)?\\/([^\\/\\n]*))?(?>\\/([^\\/\\n]*\\.json)?)?"
).toRegex()
}
val repoMatchRegex =
(
"https:\\/\\/(?>www\\.|raw\\.)?(github|githubusercontent)\\.com" +
"\\/([^\\/]+)\\/([^\\/]+)(?>(?>\\/tree|\\/blob)?\\/([^\\/\\n]*))?(?>\\/([^\\/\\n]*\\.json)?)?"
).toRegex()

View File

@@ -35,7 +35,7 @@ import suwayomi.tachidesk.graphql.types.WebUIChannel
import suwayomi.tachidesk.graphql.types.WebUIFlavor
import suwayomi.tachidesk.graphql.types.WebUIInterface
import suwayomi.tachidesk.manga.impl.backup.proto.models.BackupSettingsDownloadConversionType
import suwayomi.tachidesk.manga.impl.extension.ExtensionsList.repoMatchRegex
import suwayomi.tachidesk.manga.impl.extension.repoMatchRegex
import suwayomi.tachidesk.server.settings.BooleanSetting
import suwayomi.tachidesk.server.settings.DisableableDoubleSetting
import suwayomi.tachidesk.server.settings.DisableableIntSetting
@@ -50,6 +50,7 @@ import suwayomi.tachidesk.server.settings.PathSetting
import suwayomi.tachidesk.server.settings.SettingGroup
import suwayomi.tachidesk.server.settings.SettingsRegistry
import suwayomi.tachidesk.server.settings.StringSetting
import xyz.nulldev.ts.config.GlobalConfigManager
import xyz.nulldev.ts.config.SystemPropertyOverridableConfigModule
import kotlin.collections.associate
import kotlin.time.Duration
@@ -62,6 +63,8 @@ val mutableConfigValueScope = CoroutineScope(SupervisorJob() + Dispatchers.Defau
const val SERVER_CONFIG_MODULE_NAME = "server"
val serverConfig: ServerConfig by lazy { GlobalConfigManager.module() }
// Settings are ordered by "protoNumber".
class ServerConfig(
getConfig: () -> Config,

View File

@@ -1,7 +1,5 @@
package suwayomi.tachidesk.graphql.types
import suwayomi.tachidesk.server.serverConfig
data class AboutWebUI(
val channel: WebUIChannel,
val tag: String,
@@ -30,61 +28,3 @@ data class WebUIUpdateStatus(
val state: UpdateState,
val progress: Int,
)
enum class WebUIInterface {
BROWSER,
ELECTRON,
}
enum class WebUIChannel {
BUNDLED, // the default webUI version bundled with the server release
STABLE,
PREVIEW,
;
companion object {
fun from(channel: String): WebUIChannel = entries.find { it.name.lowercase() == channel.lowercase() } ?: STABLE
}
}
enum class WebUIFlavor(
val uiName: String,
val repoUrl: String,
val versionMappingUrl: String,
val latestReleaseInfoUrl: String,
val baseFileName: String,
) {
WEBUI(
"WebUI",
"https://github.com/Suwayomi/Suwayomi-WebUI-preview",
"https://raw.githubusercontent.com/Suwayomi/Suwayomi-WebUI/master/versionToServerVersionMapping.json",
"https://api.github.com/repos/Suwayomi/Suwayomi-WebUI-preview/releases/latest",
"Suwayomi-WebUI",
),
VUI(
"VUI",
"https://github.com/Suwayomi/Suwayomi-VUI",
"https://raw.githubusercontent.com/Suwayomi/Suwayomi-VUI/main/versionToServerVersionMapping.json",
"https://api.github.com/repos/Suwayomi/Suwayomi-VUI/releases/latest",
"Suwayomi-VUI-Web",
),
CUSTOM(
"Custom",
"repoURL",
"versionMappingUrl",
"latestReleaseInfoURL",
"baseFileName",
),
;
companion object {
val default: WebUIFlavor = WEBUI
fun from(value: String): WebUIFlavor = entries.find { it.uiName == value } ?: default
val current: WebUIFlavor
get() = serverConfig.webUIFlavor.value
}
}

View File

@@ -1,12 +0,0 @@
package suwayomi.tachidesk.manga.impl.backup.proto.models
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber
import suwayomi.tachidesk.graphql.types.SettingsDownloadConversion
@Serializable
class BackupSettingsDownloadConversionType(
@ProtoNumber(1) override val mimeType: String,
@ProtoNumber(2) override val target: String,
@ProtoNumber(3) override val compressionLevel: Double?,
) : SettingsDownloadConversion

View File

@@ -223,10 +223,4 @@ object ExtensionsList {
} else {
this
}
val repoMatchRegex =
(
"https:\\/\\/(?>www\\.|raw\\.)?(github|githubusercontent)\\.com" +
"\\/([^\\/]+)\\/([^\\/]+)(?>(?>\\/tree|\\/blob)?\\/([^\\/\\n]*))?(?>\\/([^\\/\\n]*\\.json)?)?"
).toRegex()
}

View File

@@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.App
import eu.kanade.tachiyomi.createAppModule
import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.source.local.LocalSource
import io.github.config4k.getValue
import io.github.config4k.toConfig
import io.github.oshai.kotlinlogging.KotlinLogging
import io.javalin.json.JavalinJackson
@@ -125,8 +124,6 @@ data class DatabaseSettings(
val databasePassword: String,
)
val serverConfig: ServerConfig by lazy { GlobalConfigManager.module() }
val androidCompat by lazy { AndroidCompat() }
fun setupLogLevelUpdating(