only open browser when appropriate

This commit is contained in:
Aria Moradi
2021-08-09 07:15:41 +04:30
parent a213e568ba
commit 1f9c1eb1c0
3 changed files with 15 additions and 14 deletions

View File

@@ -22,7 +22,6 @@ class SystemPropertyOverrideDelegate(val config: Config, val moduleName: String)
inline operator fun <R, reified T> getValue(thisRef: R, property: KProperty<*>): T { inline operator fun <R, reified T> getValue(thisRef: R, property: KProperty<*>): T {
val configValue: T = config.getValue(thisRef, property) val configValue: T = config.getValue(thisRef, property)
println("getting " + "suwayomi.tachidesk.config.$moduleName.${property.name}")
val combined = System.getProperty( val combined = System.getProperty(
"suwayomi.tachidesk.config.$moduleName.${property.name}", "suwayomi.tachidesk.config.$moduleName.${property.name}",
configValue.toString() configValue.toString()

View File

@@ -50,7 +50,7 @@ object JavalinSetup {
config.enableCorsForAllOrigins() config.enableCorsForAllOrigins()
}.events { event -> }.events { event ->
event.serverStarted { event.serverStarted {
if (serverConfig.webUIEnabled && serverConfig.initialOpenInBrowserEnabled) { if (serverConfig.initialOpenInBrowserEnabled) {
Browser.openInBrowser() Browser.openInBrowser()
} }
} }

View File

@@ -17,18 +17,20 @@ object Browser {
private val electronInstances = mutableListOf<Any>() private val electronInstances = mutableListOf<Any>()
fun openInBrowser() { fun openInBrowser() {
if (serverConfig.webUIBrowser == ("electron")) { if (serverConfig.webUIEnabled) {
try { if (serverConfig.webUIBrowser == ("electron")) {
val electronPath = serverConfig.electronPath try {
electronInstances.add(ProcessBuilder(electronPath, appBaseUrl).start()) val electronPath = serverConfig.electronPath
} catch (e: Throwable) { // cover both java.lang.Exception and java.lang.Error electronInstances.add(ProcessBuilder(electronPath, appBaseUrl).start())
e.printStackTrace() } catch (e: Throwable) { // cover both java.lang.Exception and java.lang.Error
} e.printStackTrace()
} else { }
try { } else {
Desktop.browseURL(appBaseUrl) try {
} catch (e: Throwable) { // cover both java.lang.Exception and java.lang.Error Desktop.browseURL(appBaseUrl)
e.printStackTrace() } catch (e: Throwable) { // cover both java.lang.Exception and java.lang.Error
e.printStackTrace()
}
} }
} }
} }