Avoid possible crash in settings viewmodel

This commit is contained in:
Juha Heinanen
2026-02-15 00:11:27 +02:00
parent 4fe3b5567f
commit 3cb05262a1

View File

@ -20,18 +20,10 @@ class SettingsViewModel: ViewModel() {
val addressFamily = MutableStateFlow("")
val transportProtocols = MutableStateFlow("")
val oldTransportProtocols = Config.variable("sip_transports")
var oldTransportProtocols = ""
val dnsServers = MutableStateFlow("")
val oldDnsServers = if (Config.variable("dyn_dns") == "yes")
""
else {
val servers = Config.variables("dns_server")
var serverList = ""
for (server in servers)
serverList += ", $server"
serverList.trimStart(',').trimStart(' ')
}
var oldDnsServers = ""
val tlsCertificateFile = MutableStateFlow(false)
val verifyServer = MutableStateFlow(false)
@ -53,6 +45,17 @@ class SettingsViewModel: ViewModel() {
fun loadSettings(ctx: Context) {
if (isLoaded) return else isLoaded = true
oldTransportProtocols = Config.variable("sip_transports")
oldDnsServers = if (Config.variable("dyn_dns") == "yes")
""
else {
val servers = Config.variables("dns_server")
var serverList = ""
for (server in servers)
serverList += ", $server"
serverList.trimStart(',').trimStart(' ')
}
autoStart.value = Config.variable("auto_start") == "yes"
listenAddress.value = Config.variable("sip_listen")