Skip to content

Commit

Permalink
Merge pull request #358 from ivpn/bugfix/set-current-server
Browse files Browse the repository at this point in the history
ServersPreference.setCurrentServer Exception:NoSuchElementException
  • Loading branch information
jurajhilje authored Aug 20, 2024
2 parents 3858928 + cf8ec08 commit 30db499
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ class ServersPreference @Inject constructor(

fun setCurrentServer(serverType: ServerType?, server: Server?) {
if (serverType == null || server == null) return
val openvpnServer = openvpnServersList?.first { it == server }
val wireguardServer = wireguardServersList?.first { it == server }
val openvpnServer = openvpnServersList?.firstOrNull { it == server }
val wireguardServer = wireguardServersList?.firstOrNull { it == server }
val serverKey = if (serverType == ServerType.ENTRY) CURRENT_ENTER_SERVER else CURRENT_EXIT_SERVER
preference.serversSharedPreferences.edit()
.putString(serverKey, Mapper.from(openvpnServer))
.apply()
.putString(serverKey, Mapper.from(openvpnServer))
.apply()
preference.wireguardServersSharedPreferences.edit()
.putString(serverKey, Mapper.from(wireguardServer))
.apply()
.putString(serverKey, Mapper.from(wireguardServer))
.apply()
}

fun putOpenVpnServerList(servers: List<Server?>?) {
Expand Down

0 comments on commit 30db499

Please sign in to comment.