summaryrefslogtreecommitdiffhomepage
path: root/android/app/src
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2022-06-17 08:22:52 +0200
committerAlbin <albin@mullvad.net>2022-06-22 11:57:30 +0200
commit7a768a8609a8b6f1dd683399c1e4d31040e2f28a (patch)
treebfd5c593294b26ba19d7149e09b2484fbcb590e7 /android/app/src
parentf01a863b20ce3b0b2c2d8828061d86b91131d516 (diff)
downloadmullvadvpn-7a768a8609a8b6f1dd683399c1e4d31040e2f28a.tar.xz
mullvadvpn-7a768a8609a8b6f1dd683399c1e4d31040e2f28a.zip
Set sharing strategy to WhileSubscribed
Diffstat (limited to 'android/app/src')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/DeviceRepository.kt6
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/DeviceRevokedViewModel.kt9
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt6
3 files changed, 15 insertions, 6 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/DeviceRepository.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/DeviceRepository.kt
index 9975b48ef9..6e50b401ec 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/DeviceRepository.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/DeviceRepository.kt
@@ -25,7 +25,11 @@ class DeviceRepository(
flowOf(DeviceState.Unknown)
}
}
- .stateIn(CoroutineScope(dispatcher), SharingStarted.Lazily, DeviceState.Initial)
+ .stateIn(
+ CoroutineScope(dispatcher),
+ SharingStarted.WhileSubscribed(),
+ DeviceState.Initial
+ )
fun refreshDeviceState() {
container()?.deviceDataSource?.refreshDevice()
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/DeviceRevokedViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/DeviceRevokedViewModel.kt
index d3975fbd08..d1749ee249 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/DeviceRevokedViewModel.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/DeviceRevokedViewModel.kt
@@ -1,6 +1,7 @@
package net.mullvad.mullvadvpn.viewmodel
import androidx.lifecycle.ViewModel
+import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.SharingStarted
@@ -17,7 +18,7 @@ import net.mullvad.talpid.util.callbackFlowFromSubscription
// ServiceConnectionManager here.
class DeviceRevokedViewModel(
private val serviceConnectionManager: ServiceConnectionManager,
- scope: CoroutineScope = CoroutineScope(Dispatchers.IO)
+ dispatcher: CoroutineDispatcher = Dispatchers.IO
) : ViewModel() {
val uiState = serviceConnectionManager.connectionState
@@ -35,9 +36,9 @@ class DeviceRevokedViewModel(
?: flowOf(DeviceRevokedUiState.UNKNOWN)
}
.stateIn(
- scope,
- SharingStarted.Lazily,
- DeviceRevokedUiState.UNKNOWN
+ scope = CoroutineScope(dispatcher),
+ started = SharingStarted.WhileSubscribed(),
+ initialValue = DeviceRevokedUiState.UNKNOWN
)
fun onGoToLoginClicked() {
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt
index 6aac2d8177..8ca0a2cde5 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt
@@ -45,7 +45,11 @@ class LoginViewModel(
emptyFlow()
}
}
- .stateIn(CoroutineScope(dispatcher), SharingStarted.Lazily, AccountHistory.Missing)
+ .stateIn(
+ scope = CoroutineScope(dispatcher),
+ started = SharingStarted.WhileSubscribed(),
+ initialValue = AccountHistory.Missing
+ )
sealed class LoginUiState {
object Default : LoginUiState()