Skip to content

Commit

Permalink
Handle device revocation on ConnectScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa authored and Pururun committed Jan 4, 2024
1 parent 2d693c2 commit 85df7eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import net.mullvad.mullvadvpn.compose.component.ScaffoldWithTopBarAndDeviceName
import net.mullvad.mullvadvpn.compose.component.drawVerticalScrollbar
import net.mullvad.mullvadvpn.compose.component.notificationbanner.NotificationBanner
import net.mullvad.mullvadvpn.compose.destinations.AccountDestination
import net.mullvad.mullvadvpn.compose.destinations.DeviceRevokedDestination
import net.mullvad.mullvadvpn.compose.destinations.OutOfTimeDestination
import net.mullvad.mullvadvpn.compose.destinations.SelectLocationDestination
import net.mullvad.mullvadvpn.compose.destinations.SettingsDestination
Expand Down Expand Up @@ -98,6 +99,12 @@ fun Connect(navigator: DestinationsNavigator) {
popUpTo(NavGraphs.root) { inclusive = true }
}
}
ConnectViewModel.UiSideEffect.RevokedDevice -> {
navigator.navigate(DeviceRevokedDestination) {
launchSingleTop = true
popUpTo(NavGraphs.root) { inclusive = true }
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import kotlinx.coroutines.flow.shareIn
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import net.mullvad.mullvadvpn.compose.state.ConnectUiState
import net.mullvad.mullvadvpn.model.DeviceState
import net.mullvad.mullvadvpn.model.GeoIpLocation
import net.mullvad.mullvadvpn.model.TunnelState
import net.mullvad.mullvadvpn.repository.AccountRepository
Expand Down Expand Up @@ -137,11 +138,17 @@ class ConnectViewModel(

init {
viewModelScope.launch {
// This once we get isOutOfTime true we will navigate to OutOfTime view.
// When we get isOutOfTime true we will navigate to OutOfTime view.
outOfTimeUseCase.isOutOfTime().first { it == true }
_uiSideEffect.send(UiSideEffect.OutOfTime)
}

viewModelScope.launch {
// When we get a revoked DeviceState we navigate to the RevokedDevice screen.
deviceRepository.deviceState.filterIsInstance<DeviceState.Revoked>().first()
_uiSideEffect.send(UiSideEffect.RevokedDevice)
}

viewModelScope.launch {
paymentUseCase.verifyPurchases { accountRepository.fetchAccountExpiry() }
}
Expand Down Expand Up @@ -194,6 +201,8 @@ class ConnectViewModel(
data class OpenAccountManagementPageInBrowser(val token: String) : UiSideEffect

data object OutOfTime : UiSideEffect

data object RevokedDevice : UiSideEffect
}

companion object {
Expand Down

0 comments on commit 85df7eb

Please sign in to comment.