canEnterRecoveryKey -> canUseRecoveryKey
This commit is contained in:
@@ -30,7 +30,7 @@ class ChooseSelfVerificationModePresenter(
|
||||
@Composable
|
||||
override fun present(): ChooseSelfVerificationModeState {
|
||||
val hasDevicesToVerifyAgainst by encryptionService.hasDevicesToVerifyAgainst.collectAsState()
|
||||
val canEnterRecoveryKey by encryptionService.recoveryStateStateFlow
|
||||
val canUseRecoveryKey by encryptionService.recoveryStateStateFlow
|
||||
.mapState { recoveryState ->
|
||||
when (recoveryState) {
|
||||
RecoveryState.WAITING_FOR_SYNC,
|
||||
@@ -44,14 +44,14 @@ class ChooseSelfVerificationModePresenter(
|
||||
val buttonsState by remember {
|
||||
derivedStateOf {
|
||||
val canUseAnotherDevice = hasDevicesToVerifyAgainst.dataOrNull()
|
||||
val canEnterRecoveryKey = canEnterRecoveryKey.dataOrNull()
|
||||
if (canUseAnotherDevice == null || canEnterRecoveryKey == null) {
|
||||
val canUseRecoveryKey = canUseRecoveryKey.dataOrNull()
|
||||
if (canUseAnotherDevice == null || canUseRecoveryKey == null) {
|
||||
AsyncData.Loading()
|
||||
} else {
|
||||
AsyncData.Success(
|
||||
ChooseSelfVerificationModeState.ButtonsState(
|
||||
canUseAnotherDevice = canUseAnotherDevice,
|
||||
canEnterRecoveryKey = canEnterRecoveryKey,
|
||||
canUseRecoveryKey = canUseRecoveryKey,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,6 @@ data class ChooseSelfVerificationModeState(
|
||||
) {
|
||||
data class ButtonsState(
|
||||
val canUseAnotherDevice: Boolean,
|
||||
val canEnterRecoveryKey: Boolean,
|
||||
val canUseRecoveryKey: Boolean,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -17,22 +17,22 @@ class ChooseSelfVerificationModeStateProvider :
|
||||
override val values = sequenceOf(
|
||||
aChooseSelfVerificationModeState(
|
||||
buttonsState = AsyncData.Success(
|
||||
aButtonsState(canUseAnotherDevice = false, canEnterRecoveryKey = true),
|
||||
aButtonsState(canUseAnotherDevice = false, canUseRecoveryKey = true),
|
||||
),
|
||||
),
|
||||
aChooseSelfVerificationModeState(
|
||||
buttonsState = AsyncData.Success(
|
||||
aButtonsState(canUseAnotherDevice = false, canEnterRecoveryKey = false),
|
||||
aButtonsState(canUseAnotherDevice = false, canUseRecoveryKey = false),
|
||||
),
|
||||
),
|
||||
aChooseSelfVerificationModeState(
|
||||
buttonsState = AsyncData.Success(
|
||||
aButtonsState(canUseAnotherDevice = true, canEnterRecoveryKey = true),
|
||||
aButtonsState(canUseAnotherDevice = true, canUseRecoveryKey = true),
|
||||
),
|
||||
),
|
||||
aChooseSelfVerificationModeState(
|
||||
buttonsState = AsyncData.Success(
|
||||
aButtonsState(canUseAnotherDevice = true, canEnterRecoveryKey = false),
|
||||
aButtonsState(canUseAnotherDevice = true, canUseRecoveryKey = false),
|
||||
),
|
||||
),
|
||||
aChooseSelfVerificationModeState(
|
||||
@@ -51,8 +51,8 @@ fun aChooseSelfVerificationModeState(
|
||||
|
||||
fun aButtonsState(
|
||||
canUseAnotherDevice: Boolean = true,
|
||||
canEnterRecoveryKey: Boolean = true,
|
||||
canUseRecoveryKey: Boolean = true,
|
||||
) = ChooseSelfVerificationModeState.ButtonsState(
|
||||
canUseAnotherDevice = canUseAnotherDevice,
|
||||
canEnterRecoveryKey = canEnterRecoveryKey,
|
||||
canUseRecoveryKey = canUseRecoveryKey,
|
||||
)
|
||||
|
||||
@@ -122,7 +122,7 @@ private fun ChooseSelfVerificationModeButtons(
|
||||
onClick = onUseAnotherDevice,
|
||||
)
|
||||
}
|
||||
if (state.buttonsState.data.canEnterRecoveryKey) {
|
||||
if (state.buttonsState.data.canUseRecoveryKey) {
|
||||
Button(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(R.string.screen_identity_confirmation_use_recovery_key),
|
||||
|
||||
@@ -47,7 +47,7 @@ class ChooseSessionVerificationModePresenterTest {
|
||||
assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo(
|
||||
ChooseSelfVerificationModeState.ButtonsState(
|
||||
canUseAnotherDevice = false,
|
||||
canEnterRecoveryKey = false,
|
||||
canUseRecoveryKey = false,
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class ChooseSessionVerificationModePresenterTest {
|
||||
assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo(
|
||||
ChooseSelfVerificationModeState.ButtonsState(
|
||||
canUseAnotherDevice = false,
|
||||
canEnterRecoveryKey = false,
|
||||
canUseRecoveryKey = false,
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class ChooseSessionVerificationModePresenterTest {
|
||||
assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo(
|
||||
ChooseSelfVerificationModeState.ButtonsState(
|
||||
canUseAnotherDevice = true,
|
||||
canEnterRecoveryKey = false,
|
||||
canUseRecoveryKey = false,
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -104,7 +104,7 @@ class ChooseSessionVerificationModePresenterTest {
|
||||
assertThat(awaitItem().buttonsState.dataOrNull()).isEqualTo(
|
||||
ChooseSelfVerificationModeState.ButtonsState(
|
||||
canUseAnotherDevice = false,
|
||||
canEnterRecoveryKey = true,
|
||||
canUseRecoveryKey = true,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class ChooseSessionVerificationModeViewTest {
|
||||
fun `clicking on enter recovery key calls the callback`() {
|
||||
ensureCalledOnce { callback ->
|
||||
rule.setChooseSelfVerificationModeView(
|
||||
aChooseSelfVerificationModeState(AsyncData.Success(aButtonsState(canEnterRecoveryKey = true))),
|
||||
aChooseSelfVerificationModeState(AsyncData.Success(aButtonsState(canUseRecoveryKey = true))),
|
||||
onEnterRecoveryKey = callback,
|
||||
)
|
||||
rule.clickOn(R.string.screen_identity_confirmation_use_recovery_key)
|
||||
|
||||
Reference in New Issue
Block a user