fix: strengthened controls on the presence of server address strings (local and remote)

This commit is contained in:
CappielloAntonio 2024-08-30 16:47:15 +02:00
parent 6f51fd92bb
commit c5a78bf945
2 changed files with 6 additions and 4 deletions

View file

@ -168,7 +168,9 @@ object Preferences {
@JvmStatic
fun getInUseServerAddress(): String? {
return App.getInstance().preferences.getString(IN_USE_SERVER_ADDRESS, getServer())
return App.getInstance().preferences.getString(IN_USE_SERVER_ADDRESS, null)
?.takeIf { it.isNotBlank() }
?: getServer()
}
@JvmStatic
@ -186,7 +188,7 @@ object Preferences {
fun isServerSwitchable(): Boolean {
return App.getInstance().preferences.getLong(
NEXT_SERVER_SWITCH, 0
) + 15000 < System.currentTimeMillis()
) + 15000 < System.currentTimeMillis() && !getServer().isNullOrEmpty() && !getLocalAddress().isNullOrEmpty()
}
@JvmStatic