Skip to content

Commit

Permalink
Add FlareSolver Session
Browse files Browse the repository at this point in the history
  • Loading branch information
Syer10 committed Jan 25, 2024
1 parent 070b76f commit 929c76a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class LauncherViewModel {
val flareSolverrEnabled = config.asStateFlow { it.flareSolverrEnabled }
val flareSolverrUrl = config.asStateFlow { it.flareSolverrUrl }
val flareSolverrTimeout = config.asStateFlow { it.flareSolverrTimeout }
val flareSolverrSessionName = config.asStateFlow { it.flareSolverrSessionName }
val flareSolverrSessionTtl = config.asStateFlow { it.flareSolverrSessionTtl }

val theme = settings.theme().asStateFlow(scope)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,6 @@ class ServerConfig(
val flareSolverrEnabled: MutableStateFlow<Boolean> by OverrideConfigValue(BooleanConfigAdapter)
val flareSolverrUrl: MutableStateFlow<String> by OverrideConfigValue(StringConfigAdapter)
val flareSolverrTimeout: MutableStateFlow<Int> by OverrideConfigValue(IntConfigAdapter)
val flareSolverrSessionName: MutableStateFlow<String> by OverrideConfigValue(StringConfigAdapter)
val flareSolverrSessionTtl: MutableStateFlow<Int> by OverrideConfigValue(IntConfigAdapter)
}
33 changes: 33 additions & 0 deletions src/main/kotlin/suwayomi/tachidesk/launcher/ui/Cloudflare.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,37 @@ fun Cloudflare(vm: LauncherViewModel, scope: CoroutineScope) = jpanel(
.flowOn(Dispatchers.Default)
.launchIn(scope)
}.bind(CC().grow().spanX().wrap())

jTextArea("FlareSolverr Session") {
isEditable = false
}.bind()
jTextField(vm.flareSolverrSessionName.value) {
toolTipText = "FlareSolver session name"
keyListener()
.filterIsInstance<KeyListenerEvent.Released>()
.map {
text?.trim()
}
.onEach {
if (!it.isNullOrBlank()) {
vm.flareSolverrSessionName.value = it
}
}
.flowOn(Dispatchers.Default)
.launchIn(scope)
columns = 10
}.bind(CC().grow().spanX().wrap())

jTextArea("FlareSolverr Session TTL") {
isEditable = false
}.bind()
jSpinner(SpinnerNumberModel(vm.flareSolverrSessionTtl.value.coerceAtLeast(2), 2, Int.MAX_VALUE, 1)) {
toolTipText = "FlareSolverr session time to live in minutes"
changes()
.onEach {
vm.flareSolverrSessionTtl.value = (value as Int)
}
.flowOn(Dispatchers.Default)
.launchIn(scope)
}.bind(CC().grow().spanX().wrap())
}

0 comments on commit 929c76a

Please sign in to comment.