canEnterRecoveryKey -> canUseRecoveryKey

This commit is contained in:
Benoit Marty 2026-03-16 17:21:19 +01:00
parent b5830f5016
commit afa1a42d92
6 changed files with 17 additions and 17 deletions

View file

@ -30,7 +30,7 @@ class ChooseSelfVerificationModePresenter(
@Composable @Composable
override fun present(): ChooseSelfVerificationModeState { override fun present(): ChooseSelfVerificationModeState {
val hasDevicesToVerifyAgainst by encryptionService.hasDevicesToVerifyAgainst.collectAsState() val hasDevicesToVerifyAgainst by encryptionService.hasDevicesToVerifyAgainst.collectAsState()
val canEnterRecoveryKey by encryptionService.recoveryStateStateFlow val canUseRecoveryKey by encryptionService.recoveryStateStateFlow
.mapState { recoveryState -> .mapState { recoveryState ->
when (recoveryState) { when (recoveryState) {
RecoveryState.WAITING_FOR_SYNC, RecoveryState.WAITING_FOR_SYNC,
@ -44,14 +44,14 @@ class ChooseSelfVerificationModePresenter(
val buttonsState by remember { val buttonsState by remember {
derivedStateOf { derivedStateOf {
val canUseAnotherDevice = hasDevicesToVerifyAgainst.dataOrNull() val canUseAnotherDevice = hasDevicesToVerifyAgainst.dataOrNull()
val canEnterRecoveryKey = canEnterRecoveryKey.dataOrNull() val canUseRecoveryKey = canUseRecoveryKey.dataOrNull()
if (canUseAnotherDevice == null || canEnterRecoveryKey == null) { if (canUseAnotherDevice == null || canUseRecoveryKey == null) {
AsyncData.Loading() AsyncData.Loading()
} else { } else {
AsyncData.Success( AsyncData.Success(
ChooseSelfVerificationModeState.ButtonsState( ChooseSelfVerificationModeState.ButtonsState(
canUseAnotherDevice = canUseAnotherDevice, canUseAnotherDevice = canUseAnotherDevice,
canEnterRecoveryKey = canEnterRecoveryKey, canUseRecoveryKey = canUseRecoveryKey,
) )
) )
} }

View file

@ -18,6 +18,6 @@ data class ChooseSelfVerificationModeState(
) { ) {
data class ButtonsState( data class ButtonsState(
val canUseAnotherDevice: Boolean, val canUseAnotherDevice: Boolean,
val canEnterRecoveryKey: Boolean, val canUseRecoveryKey: Boolean,
) )
} }

View file

@ -17,22 +17,22 @@ class ChooseSelfVerificationModeStateProvider :
override val values = sequenceOf( override val values = sequenceOf(
aChooseSelfVerificationModeState( aChooseSelfVerificationModeState(
buttonsState = AsyncData.Success( buttonsState = AsyncData.Success(
aButtonsState(canUseAnotherDevice = false, canEnterRecoveryKey = true), aButtonsState(canUseAnotherDevice = false, canUseRecoveryKey = true),
), ),
), ),
aChooseSelfVerificationModeState( aChooseSelfVerificationModeState(
buttonsState = AsyncData.Success( buttonsState = AsyncData.Success(
aButtonsState(canUseAnotherDevice = false, canEnterRecoveryKey = false), aButtonsState(canUseAnotherDevice = false, canUseRecoveryKey = false),
), ),
), ),
aChooseSelfVerificationModeState( aChooseSelfVerificationModeState(
buttonsState = AsyncData.Success( buttonsState = AsyncData.Success(
aButtonsState(canUseAnotherDevice = true, canEnterRecoveryKey = true), aButtonsState(canUseAnotherDevice = true, canUseRecoveryKey = true),
), ),
), ),
aChooseSelfVerificationModeState( aChooseSelfVerificationModeState(
buttonsState = AsyncData.Success( buttonsState = AsyncData.Success(
aButtonsState(canUseAnotherDevice = true, canEnterRecoveryKey = false), aButtonsState(canUseAnotherDevice = true, canUseRecoveryKey = false),
), ),
), ),
aChooseSelfVerificationModeState( aChooseSelfVerificationModeState(
@ -51,8 +51,8 @@ fun aChooseSelfVerificationModeState(
fun aButtonsState( fun aButtonsState(
canUseAnotherDevice: Boolean = true, canUseAnotherDevice: Boolean = true,
canEnterRecoveryKey: Boolean = true, canUseRecoveryKey: Boolean = true,
) = ChooseSelfVerificationModeState.ButtonsState( ) = ChooseSelfVerificationModeState.ButtonsState(
canUseAnotherDevice = canUseAnotherDevice, canUseAnotherDevice = canUseAnotherDevice,
canEnterRecoveryKey = canEnterRecoveryKey, canUseRecoveryKey = canUseRecoveryKey,
) )

View file

@ -122,7 +122,7 @@ private fun ChooseSelfVerificationModeButtons(
onClick = onUseAnotherDevice, onClick = onUseAnotherDevice,
) )
} }
if (state.buttonsState.data.canEnterRecoveryKey) { if (state.buttonsState.data.canUseRecoveryKey) {
Button( Button(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
text = stringResource(R.string.screen_identity_confirmation_use_recovery_key), text = stringResource(R.string.screen_identity_confirmation_use_recovery_key),

View file

@ -47,7 +47,7 @@ class ChooseSessionVerificationModePresenterTest {
assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo( assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo(
ChooseSelfVerificationModeState.ButtonsState( ChooseSelfVerificationModeState.ButtonsState(
canUseAnotherDevice = false, canUseAnotherDevice = false,
canEnterRecoveryKey = false, canUseRecoveryKey = false,
) )
) )
} }
@ -66,7 +66,7 @@ class ChooseSessionVerificationModePresenterTest {
assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo( assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo(
ChooseSelfVerificationModeState.ButtonsState( ChooseSelfVerificationModeState.ButtonsState(
canUseAnotherDevice = false, canUseAnotherDevice = false,
canEnterRecoveryKey = false, canUseRecoveryKey = false,
) )
) )
} }
@ -85,7 +85,7 @@ class ChooseSessionVerificationModePresenterTest {
assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo( assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo(
ChooseSelfVerificationModeState.ButtonsState( ChooseSelfVerificationModeState.ButtonsState(
canUseAnotherDevice = true, canUseAnotherDevice = true,
canEnterRecoveryKey = false, canUseRecoveryKey = false,
) )
) )
} }
@ -104,7 +104,7 @@ class ChooseSessionVerificationModePresenterTest {
assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo( assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo(
ChooseSelfVerificationModeState.ButtonsState( ChooseSelfVerificationModeState.ButtonsState(
canUseAnotherDevice = false, canUseAnotherDevice = false,
canEnterRecoveryKey = true, canUseRecoveryKey = true,
) )
) )
} }

View file

@ -57,7 +57,7 @@ class ChooseSessionVerificationModeViewTest {
fun `clicking on enter recovery key calls the callback`() { fun `clicking on enter recovery key calls the callback`() {
ensureCalledOnce { callback -> ensureCalledOnce { callback ->
rule.setChooseSelfVerificationModeView( rule.setChooseSelfVerificationModeView(
aChooseSelfVerificationModeState(AsyncData.Success(aButtonsState(canEnterRecoveryKey = true))), aChooseSelfVerificationModeState(AsyncData.Success(aButtonsState(canUseRecoveryKey = true))),
onEnterRecoveryKey = callback, onEnterRecoveryKey = callback,
) )
rule.clickOn(R.string.screen_identity_confirmation_use_recovery_key) rule.clickOn(R.string.screen_identity_confirmation_use_recovery_key)