mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 06:42:07 +01:00
Add missing settings to gql (#738)
* Add missing settings to gql * Cleanup updating settings
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package suwayomi.tachidesk.graphql.mutations
|
||||
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import suwayomi.tachidesk.graphql.types.PartialSettingsType
|
||||
import suwayomi.tachidesk.graphql.types.Settings
|
||||
import suwayomi.tachidesk.graphql.types.SettingsType
|
||||
@@ -19,99 +20,68 @@ class SettingsMutation {
|
||||
val settings: SettingsType,
|
||||
)
|
||||
|
||||
private fun <SettingType : Any> updateSetting(
|
||||
newSetting: SettingType?,
|
||||
configSetting: MutableStateFlow<SettingType>,
|
||||
) {
|
||||
if (newSetting == null) {
|
||||
return
|
||||
}
|
||||
|
||||
configSetting.value = newSetting
|
||||
}
|
||||
|
||||
private fun updateSettings(settings: Settings) {
|
||||
if (settings.ip != null) serverConfig.ip.value = settings.ip!!
|
||||
if (settings.port != null) serverConfig.port.value = settings.port!!
|
||||
updateSetting(settings.ip, serverConfig.ip)
|
||||
updateSetting(settings.port, serverConfig.port)
|
||||
|
||||
if (settings.socksProxyEnabled != null) {
|
||||
serverConfig.socksProxyEnabled.value = settings.socksProxyEnabled!!
|
||||
}
|
||||
if (settings.socksProxyHost != null) {
|
||||
serverConfig.socksProxyHost.value = settings.socksProxyHost!!
|
||||
}
|
||||
if (settings.socksProxyPort != null) {
|
||||
serverConfig.socksProxyPort.value = settings.socksProxyPort!!
|
||||
}
|
||||
// proxy
|
||||
updateSetting(settings.socksProxyEnabled, serverConfig.socksProxyEnabled)
|
||||
updateSetting(settings.socksProxyHost, serverConfig.socksProxyHost)
|
||||
updateSetting(settings.socksProxyPort, serverConfig.socksProxyPort)
|
||||
|
||||
if (settings.webUIFlavor != null) {
|
||||
serverConfig.webUIFlavor.value = settings.webUIFlavor!!.uiName
|
||||
}
|
||||
if (settings.initialOpenInBrowserEnabled != null) {
|
||||
serverConfig.initialOpenInBrowserEnabled.value = settings.initialOpenInBrowserEnabled!!
|
||||
}
|
||||
if (settings.webUIInterface != null) {
|
||||
serverConfig.webUIInterface.value = settings.webUIInterface!!.name.lowercase()
|
||||
}
|
||||
if (settings.electronPath != null) {
|
||||
serverConfig.electronPath.value = settings.electronPath!!
|
||||
}
|
||||
if (settings.webUIChannel != null) {
|
||||
serverConfig.webUIChannel.value = settings.webUIChannel!!.name.lowercase()
|
||||
}
|
||||
if (settings.webUIUpdateCheckInterval != null) {
|
||||
serverConfig.webUIUpdateCheckInterval.value = settings.webUIUpdateCheckInterval!!
|
||||
}
|
||||
// webUI
|
||||
updateSetting(settings.webUIFlavor?.uiName, serverConfig.webUIFlavor)
|
||||
updateSetting(settings.initialOpenInBrowserEnabled, serverConfig.initialOpenInBrowserEnabled)
|
||||
updateSetting(settings.webUIInterface?.name?.lowercase(), serverConfig.webUIInterface)
|
||||
updateSetting(settings.electronPath, serverConfig.electronPath)
|
||||
updateSetting(settings.webUIChannel?.name?.lowercase(), serverConfig.webUIChannel)
|
||||
updateSetting(settings.webUIUpdateCheckInterval, serverConfig.webUIUpdateCheckInterval)
|
||||
|
||||
if (settings.downloadAsCbz != null) {
|
||||
serverConfig.downloadAsCbz.value = settings.downloadAsCbz!!
|
||||
}
|
||||
if (settings.downloadsPath != null) {
|
||||
serverConfig.downloadsPath.value = settings.downloadsPath!!
|
||||
}
|
||||
if (settings.autoDownloadNewChapters != null) {
|
||||
serverConfig.autoDownloadNewChapters.value = settings.autoDownloadNewChapters!!
|
||||
}
|
||||
// downloader
|
||||
updateSetting(settings.downloadAsCbz, serverConfig.downloadAsCbz)
|
||||
updateSetting(settings.downloadsPath, serverConfig.downloadsPath)
|
||||
updateSetting(settings.autoDownloadNewChapters, serverConfig.autoDownloadNewChapters)
|
||||
updateSetting(settings.excludeEntryWithUnreadChapters, serverConfig.excludeEntryWithUnreadChapters)
|
||||
updateSetting(settings.autoDownloadAheadLimit, serverConfig.autoDownloadAheadLimit)
|
||||
|
||||
if (settings.maxSourcesInParallel != null) {
|
||||
serverConfig.maxSourcesInParallel.value = settings.maxSourcesInParallel!!
|
||||
}
|
||||
// requests
|
||||
updateSetting(settings.maxSourcesInParallel, serverConfig.maxSourcesInParallel)
|
||||
|
||||
if (settings.excludeUnreadChapters != null) {
|
||||
serverConfig.excludeUnreadChapters.value = settings.excludeUnreadChapters!!
|
||||
}
|
||||
if (settings.excludeNotStarted != null) {
|
||||
serverConfig.excludeNotStarted.value = settings.excludeNotStarted!!
|
||||
}
|
||||
if (settings.excludeCompleted != null) {
|
||||
serverConfig.excludeCompleted.value = settings.excludeCompleted!!
|
||||
}
|
||||
if (settings.globalUpdateInterval != null) {
|
||||
serverConfig.globalUpdateInterval.value = settings.globalUpdateInterval!!
|
||||
}
|
||||
// updater
|
||||
updateSetting(settings.excludeUnreadChapters, serverConfig.excludeUnreadChapters)
|
||||
updateSetting(settings.excludeNotStarted, serverConfig.excludeNotStarted)
|
||||
updateSetting(settings.excludeCompleted, serverConfig.excludeCompleted)
|
||||
updateSetting(settings.globalUpdateInterval, serverConfig.globalUpdateInterval)
|
||||
|
||||
if (settings.basicAuthEnabled != null) {
|
||||
serverConfig.basicAuthEnabled.value = settings.basicAuthEnabled!!
|
||||
}
|
||||
if (settings.basicAuthUsername != null) {
|
||||
serverConfig.basicAuthUsername.value = settings.basicAuthUsername!!
|
||||
}
|
||||
if (settings.basicAuthPassword != null) {
|
||||
serverConfig.basicAuthPassword.value = settings.basicAuthPassword!!
|
||||
}
|
||||
// Authentication
|
||||
updateSetting(settings.basicAuthEnabled, serverConfig.basicAuthEnabled)
|
||||
updateSetting(settings.basicAuthUsername, serverConfig.basicAuthUsername)
|
||||
updateSetting(settings.basicAuthPassword, serverConfig.basicAuthPassword)
|
||||
|
||||
if (settings.debugLogsEnabled != null) {
|
||||
serverConfig.debugLogsEnabled.value = settings.debugLogsEnabled!!
|
||||
}
|
||||
if (settings.systemTrayEnabled != null) {
|
||||
serverConfig.systemTrayEnabled.value = settings.systemTrayEnabled!!
|
||||
}
|
||||
// misc
|
||||
updateSetting(settings.debugLogsEnabled, serverConfig.debugLogsEnabled)
|
||||
updateSetting(settings.gqlDebugLogsEnabled, serverConfig.gqlDebugLogsEnabled)
|
||||
updateSetting(settings.systemTrayEnabled, serverConfig.systemTrayEnabled)
|
||||
|
||||
if (settings.backupPath != null) {
|
||||
serverConfig.backupPath.value = settings.backupPath!!
|
||||
}
|
||||
if (settings.backupTime != null) {
|
||||
serverConfig.backupTime.value = settings.backupTime!!
|
||||
}
|
||||
if (settings.backupInterval != null) {
|
||||
serverConfig.backupInterval.value = settings.backupInterval!!
|
||||
}
|
||||
if (settings.backupTTL != null) {
|
||||
serverConfig.backupTTL.value = settings.backupTTL!!
|
||||
}
|
||||
// backup
|
||||
updateSetting(settings.backupPath, serverConfig.backupPath)
|
||||
updateSetting(settings.backupTime, serverConfig.backupTime)
|
||||
updateSetting(settings.backupInterval, serverConfig.backupInterval)
|
||||
updateSetting(settings.backupTTL, serverConfig.backupTTL)
|
||||
|
||||
if (settings.localSourcePath != null) {
|
||||
serverConfig.localSourcePath.value = settings.localSourcePath!!
|
||||
}
|
||||
// local source
|
||||
updateSetting(settings.localSourcePath, serverConfig.localSourcePath)
|
||||
}
|
||||
|
||||
fun setSettings(input: SetSettingsInput): SetSettingsPayload {
|
||||
|
||||
@@ -37,6 +37,8 @@ interface Settings : Node {
|
||||
val downloadAsCbz: Boolean?
|
||||
val downloadsPath: String?
|
||||
val autoDownloadNewChapters: Boolean?
|
||||
val excludeEntryWithUnreadChapters: Boolean?
|
||||
val autoDownloadAheadLimit: Int?
|
||||
|
||||
// requests
|
||||
val maxSourcesInParallel: Int?
|
||||
@@ -54,6 +56,7 @@ interface Settings : Node {
|
||||
|
||||
// misc
|
||||
val debugLogsEnabled: Boolean?
|
||||
val gqlDebugLogsEnabled: Boolean?
|
||||
val systemTrayEnabled: Boolean?
|
||||
|
||||
// backup
|
||||
@@ -84,6 +87,8 @@ data class PartialSettingsType(
|
||||
override val downloadAsCbz: Boolean?,
|
||||
override val downloadsPath: String?,
|
||||
override val autoDownloadNewChapters: Boolean?,
|
||||
override val excludeEntryWithUnreadChapters: Boolean?,
|
||||
override val autoDownloadAheadLimit: Int?,
|
||||
// requests
|
||||
override val maxSourcesInParallel: Int?,
|
||||
// updater
|
||||
@@ -97,6 +102,7 @@ data class PartialSettingsType(
|
||||
override val basicAuthPassword: String?,
|
||||
// misc
|
||||
override val debugLogsEnabled: Boolean?,
|
||||
override val gqlDebugLogsEnabled: Boolean?,
|
||||
override val systemTrayEnabled: Boolean?,
|
||||
// backup
|
||||
override val backupPath: String?,
|
||||
@@ -125,6 +131,8 @@ class SettingsType(
|
||||
override val downloadAsCbz: Boolean,
|
||||
override val downloadsPath: String,
|
||||
override val autoDownloadNewChapters: Boolean,
|
||||
override val excludeEntryWithUnreadChapters: Boolean?,
|
||||
override val autoDownloadAheadLimit: Int?,
|
||||
// requests
|
||||
override val maxSourcesInParallel: Int,
|
||||
// updater
|
||||
@@ -138,6 +146,7 @@ class SettingsType(
|
||||
override val basicAuthPassword: String,
|
||||
// misc
|
||||
override val debugLogsEnabled: Boolean,
|
||||
override val gqlDebugLogsEnabled: Boolean?,
|
||||
override val systemTrayEnabled: Boolean,
|
||||
// backup
|
||||
override val backupPath: String,
|
||||
@@ -150,32 +159,44 @@ class SettingsType(
|
||||
constructor(config: ServerConfig = serverConfig) : this(
|
||||
config.ip.value,
|
||||
config.port.value,
|
||||
// proxy
|
||||
config.socksProxyEnabled.value,
|
||||
config.socksProxyHost.value,
|
||||
config.socksProxyPort.value,
|
||||
// webUI
|
||||
WebUIFlavor.from(config.webUIFlavor.value),
|
||||
config.initialOpenInBrowserEnabled.value,
|
||||
WebUIInterface.from(config.webUIInterface.value),
|
||||
config.electronPath.value,
|
||||
WebUIChannel.from(config.webUIChannel.value),
|
||||
config.webUIUpdateCheckInterval.value,
|
||||
// downloader
|
||||
config.downloadAsCbz.value,
|
||||
config.downloadsPath.value,
|
||||
config.autoDownloadNewChapters.value,
|
||||
config.excludeEntryWithUnreadChapters.value,
|
||||
config.autoDownloadAheadLimit.value,
|
||||
// requests
|
||||
config.maxSourcesInParallel.value,
|
||||
// updater
|
||||
config.excludeUnreadChapters.value,
|
||||
config.excludeNotStarted.value,
|
||||
config.excludeCompleted.value,
|
||||
config.globalUpdateInterval.value,
|
||||
// Authentication
|
||||
config.basicAuthEnabled.value,
|
||||
config.basicAuthUsername.value,
|
||||
config.basicAuthPassword.value,
|
||||
// misc
|
||||
config.debugLogsEnabled.value,
|
||||
config.gqlDebugLogsEnabled.value,
|
||||
config.systemTrayEnabled.value,
|
||||
// backup
|
||||
config.backupPath.value,
|
||||
config.backupTime.value,
|
||||
config.backupInterval.value,
|
||||
config.backupTTL.value,
|
||||
// local source
|
||||
config.localSourcePath.value,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user