diff options
| author | Albin <albin@mullvad.net> | 2022-06-17 08:22:52 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2022-06-22 11:57:30 +0200 |
| commit | 7a768a8609a8b6f1dd683399c1e4d31040e2f28a (patch) | |
| tree | bfd5c593294b26ba19d7149e09b2484fbcb590e7 /android/app/src | |
| parent | f01a863b20ce3b0b2c2d8828061d86b91131d516 (diff) | |
| download | mullvadvpn-7a768a8609a8b6f1dd683399c1e4d31040e2f28a.tar.xz mullvadvpn-7a768a8609a8b6f1dd683399c1e4d31040e2f28a.zip | |
Set sharing strategy to WhileSubscribed
Diffstat (limited to 'android/app/src')
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() |
