Avoid possible crash in settings viewmodel
This commit is contained in:
@@ -20,18 +20,10 @@ class SettingsViewModel: ViewModel() {
|
|||||||
val addressFamily = MutableStateFlow("")
|
val addressFamily = MutableStateFlow("")
|
||||||
|
|
||||||
val transportProtocols = MutableStateFlow("")
|
val transportProtocols = MutableStateFlow("")
|
||||||
val oldTransportProtocols = Config.variable("sip_transports")
|
var oldTransportProtocols = ""
|
||||||
|
|
||||||
val dnsServers = MutableStateFlow("")
|
val dnsServers = MutableStateFlow("")
|
||||||
val oldDnsServers = if (Config.variable("dyn_dns") == "yes")
|
var oldDnsServers = ""
|
||||||
""
|
|
||||||
else {
|
|
||||||
val servers = Config.variables("dns_server")
|
|
||||||
var serverList = ""
|
|
||||||
for (server in servers)
|
|
||||||
serverList += ", $server"
|
|
||||||
serverList.trimStart(',').trimStart(' ')
|
|
||||||
}
|
|
||||||
|
|
||||||
val tlsCertificateFile = MutableStateFlow(false)
|
val tlsCertificateFile = MutableStateFlow(false)
|
||||||
val verifyServer = MutableStateFlow(false)
|
val verifyServer = MutableStateFlow(false)
|
||||||
@@ -53,6 +45,17 @@ class SettingsViewModel: ViewModel() {
|
|||||||
fun loadSettings(ctx: Context) {
|
fun loadSettings(ctx: Context) {
|
||||||
if (isLoaded) return else isLoaded = true
|
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"
|
autoStart.value = Config.variable("auto_start") == "yes"
|
||||||
|
|
||||||
listenAddress.value = Config.variable("sip_listen")
|
listenAddress.value = Config.variable("sip_listen")
|
||||||
|
|||||||
Reference in New Issue
Block a user