From 0a09bcb09c920421a897644ddb799c5be1598e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Zolnai?= Date: Thu, 20 Jun 2024 09:30:00 +0200 Subject: [PATCH] Fix being able to fetch multiple profiles --- .../java/nl/eduvpn/app/fragment/ServerSelectionFragment.kt | 1 - app/src/main/java/nl/eduvpn/app/service/WireGuardService.kt | 2 +- .../java/nl/eduvpn/app/viewmodel/BaseConnectionViewModel.kt | 1 + app/src/main/java/nl/eduvpn/app/viewmodel/MainViewModel.kt | 2 +- .../java/nl/eduvpn/app/viewmodel/ServerSelectionViewModel.kt | 3 +-- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/nl/eduvpn/app/fragment/ServerSelectionFragment.kt b/app/src/main/java/nl/eduvpn/app/fragment/ServerSelectionFragment.kt index dd9aa8b4..793dba63 100644 --- a/app/src/main/java/nl/eduvpn/app/fragment/ServerSelectionFragment.kt +++ b/app/src/main/java/nl/eduvpn/app/fragment/ServerSelectionFragment.kt @@ -23,7 +23,6 @@ import android.os.Bundle import android.view.View import androidx.appcompat.app.AlertDialog import androidx.fragment.app.viewModels -import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.snackbar.Snackbar import nl.eduvpn.app.BuildConfig diff --git a/app/src/main/java/nl/eduvpn/app/service/WireGuardService.kt b/app/src/main/java/nl/eduvpn/app/service/WireGuardService.kt index 548f0608..c42e3668 100644 --- a/app/src/main/java/nl/eduvpn/app/service/WireGuardService.kt +++ b/app/src/main/java/nl/eduvpn/app/service/WireGuardService.kt @@ -127,7 +127,7 @@ class WireGuardService(private val context: Context, timer: Flow): VPNServ withContext(Dispatchers.Main) { pendingConfig = config authorizeVPN(activity) - setConnectionStatus(VPNStatus.DISCONNECTED) + setConnectionStatus(VPNStatus.CONNECTING) } } else { fail(ex.toString()) diff --git a/app/src/main/java/nl/eduvpn/app/viewmodel/BaseConnectionViewModel.kt b/app/src/main/java/nl/eduvpn/app/viewmodel/BaseConnectionViewModel.kt index a3bcb967..ee2831d2 100644 --- a/app/src/main/java/nl/eduvpn/app/viewmodel/BaseConnectionViewModel.kt +++ b/app/src/main/java/nl/eduvpn/app/viewmodel/BaseConnectionViewModel.kt @@ -99,6 +99,7 @@ abstract class BaseConnectionViewModel( } fun getProfiles(instance: Instance) { + connectionState.value = ConnectionState.FetchingProfiles viewModelScope.launch(Dispatchers.IO) { try { preferencesService.setCurrentInstance(instance) diff --git a/app/src/main/java/nl/eduvpn/app/viewmodel/MainViewModel.kt b/app/src/main/java/nl/eduvpn/app/viewmodel/MainViewModel.kt index 85a19578..8a77db73 100644 --- a/app/src/main/java/nl/eduvpn/app/viewmodel/MainViewModel.kt +++ b/app/src/main/java/nl/eduvpn/app/viewmodel/MainViewModel.kt @@ -120,7 +120,7 @@ class MainViewModel @Inject constructor( backendService.startProxyguard(config.proxy) } catch (ex: CommonException) { // These are just warnings, so we log them, but don't display to the user - Log.w( TAG, "Unable to start failover detection", ex) + Log.w( TAG, "Unable to start Proxyguard detection", ex) } } } diff --git a/app/src/main/java/nl/eduvpn/app/viewmodel/ServerSelectionViewModel.kt b/app/src/main/java/nl/eduvpn/app/viewmodel/ServerSelectionViewModel.kt index e5e86b23..2911a636 100644 --- a/app/src/main/java/nl/eduvpn/app/viewmodel/ServerSelectionViewModel.kt +++ b/app/src/main/java/nl/eduvpn/app/viewmodel/ServerSelectionViewModel.kt @@ -44,8 +44,8 @@ class ServerSelectionViewModel @Inject constructor( context: Context, backendService: BackendService, private val historyService: HistoryService, - private val preferencesService: PreferencesService, private val organizationService: OrganizationService, + preferencesService: PreferencesService, vpnConnectionService: VPNConnectionService, ) : BaseConnectionViewModel( context, @@ -155,6 +155,5 @@ class ServerSelectionViewModel @Inject constructor( companion object { private val TAG = ServerSelectionViewModel::class.java.name - private const val SERVER_LIST_CACHE_TTL = 15 * 60 * 1_000L // 15 minutes } }