Do not show verification banner for the last device, show the enter recovery key banner.
This commit is contained in:
parent
6cd28b2305
commit
4a75e6a9a7
2 changed files with 36 additions and 11 deletions
|
|
@ -109,22 +109,23 @@ class RoomListPresenter @Inject constructor(
|
||||||
val isMigrating = migrationScreenPresenter.present().isMigrating
|
val isMigrating = migrationScreenPresenter.present().isMigrating
|
||||||
|
|
||||||
var securityBannerDismissed by rememberSaveable { mutableStateOf(false) }
|
var securityBannerDismissed by rememberSaveable { mutableStateOf(false) }
|
||||||
val displayVerificationPrompt by sessionVerificationService.canVerifySessionFlow.collectAsState(initial = false)
|
val canVerifySession by sessionVerificationService.canVerifySessionFlow.collectAsState(initial = false)
|
||||||
val recoveryState by encryptionService.recoveryStateStateFlow.collectAsState()
|
var isLastDevice by remember { mutableStateOf(false) }
|
||||||
val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage)
|
LaunchedEffect(Unit) {
|
||||||
.collectAsState(initial = null)
|
isLastDevice = encryptionService.isLastDevice().getOrNull() ?: false
|
||||||
val displayRecoveryKeyPrompt by remember {
|
|
||||||
derivedStateOf {
|
|
||||||
secureStorageFlag == true &&
|
|
||||||
recoveryState == RecoveryState.INCOMPLETE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
val recoveryState by encryptionService.recoveryStateStateFlow.collectAsState()
|
||||||
|
val secureStorageFlag by featureFlagService.isFeatureEnabledFlow(FeatureFlags.SecureStorage).collectAsState(initial = null)
|
||||||
val securityBannerState by remember {
|
val securityBannerState by remember {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
when {
|
when {
|
||||||
securityBannerDismissed -> SecurityBannerState.None
|
securityBannerDismissed -> SecurityBannerState.None
|
||||||
displayVerificationPrompt -> SecurityBannerState.SessionVerification
|
canVerifySession -> if (isLastDevice) {
|
||||||
displayRecoveryKeyPrompt -> SecurityBannerState.RecoveryKeyConfirmation
|
SecurityBannerState.RecoveryKeyConfirmation
|
||||||
|
} else {
|
||||||
|
SecurityBannerState.SessionVerification
|
||||||
|
}
|
||||||
|
secureStorageFlag == true && recoveryState == RecoveryState.INCOMPLETE -> SecurityBannerState.RecoveryKeyConfirmation
|
||||||
else -> SecurityBannerState.None
|
else -> SecurityBannerState.None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,30 @@ class RoomListPresenterTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - handle RecoveryKeyConfirmation last session`() = runTest {
|
||||||
|
val scope = CoroutineScope(context = coroutineContext + SupervisorJob())
|
||||||
|
val presenter = createRoomListPresenter(
|
||||||
|
coroutineScope = scope,
|
||||||
|
client = FakeMatrixClient(
|
||||||
|
encryptionService = FakeEncryptionService().apply {
|
||||||
|
givenIsLastDevice(true)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
|
presenter.present()
|
||||||
|
}.test {
|
||||||
|
skipItems(2)
|
||||||
|
val eventSink = awaitItem().eventSink
|
||||||
|
// For the last session, the state is not SessionVerification, but RecoveryKeyConfirmation
|
||||||
|
assertThat(awaitItem().securityBannerState).isEqualTo(SecurityBannerState.RecoveryKeyConfirmation)
|
||||||
|
eventSink(RoomListEvents.DismissRequestVerificationPrompt)
|
||||||
|
assertThat(awaitItem().securityBannerState).isEqualTo(SecurityBannerState.None)
|
||||||
|
scope.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - handle DismissRequestVerificationPrompt`() = runTest {
|
fun `present - handle DismissRequestVerificationPrompt`() = runTest {
|
||||||
val scope = CoroutineScope(context = coroutineContext + SupervisorJob())
|
val scope = CoroutineScope(context = coroutineContext + SupervisorJob())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue