Make isLastSession "live"

This commit is contained in:
Benoit Marty 2024-02-21 10:33:08 +01:00 committed by Benoit Marty
parent daa90a0660
commit 6ddc2f5814
9 changed files with 32 additions and 33 deletions

View file

@ -113,10 +113,7 @@ class RoomListPresenter @Inject constructor(
var securityBannerDismissed by rememberSaveable { mutableStateOf(false) }
val canVerifySession by sessionVerificationService.canVerifySessionFlow.collectAsState(initial = false)
var isLastDevice by remember { mutableStateOf(false) }
LaunchedEffect(Unit) {
isLastDevice = encryptionService.isLastDevice().getOrNull() ?: false
}
val isLastDevice by encryptionService.isLastDevice.collectAsState()
val recoveryState by encryptionService.recoveryStateStateFlow.collectAsState()
val syncState by syncService.syncState.collectAsState()
val securityBannerState by remember {

View file

@ -243,14 +243,14 @@ class RoomListPresenterTests {
coroutineScope = scope,
client = FakeMatrixClient(
encryptionService = FakeEncryptionService().apply {
givenIsLastDevice(true)
emitIsLastDevice(true)
}
),
)
moleculeFlow(RecompositionMode.Immediate) {
presenter.present()
}.test {
skipItems(2)
skipItems(1)
val eventSink = awaitItem().eventSink
// For the last session, the state is not SessionVerification, but RecoveryKeyConfirmation
assertThat(awaitItem().securityBannerState).isEqualTo(SecurityBannerState.RecoveryKeyConfirmation)