canEnterRecoveryKey -> canUseRecoveryKey
This commit is contained in:
parent
b5830f5016
commit
afa1a42d92
6 changed files with 17 additions and 17 deletions
|
|
@ -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,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -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),
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue