Tweak the onboarding flow identity confirmation screen
- hide the recovery key option if recovery wasn't set up beforehand - add a button to present the reset encryption instructions screen
This commit is contained in:
committed by
Stefan Ceriu
parent
b55eb7d19e
commit
c9f256aa36
@@ -212,6 +212,8 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
||||
case .skip:
|
||||
appSettings.hasRunIdentityConfirmationOnboarding = true
|
||||
stateMachine.tryEvent(.next)
|
||||
case .reset:
|
||||
presentResetRecoveryKeyScreen()
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -30,6 +30,7 @@ enum IdentityConfirmationScreenCoordinatorAction {
|
||||
case recoveryKey
|
||||
/// Only possible in debug builds.
|
||||
case skip
|
||||
case reset
|
||||
}
|
||||
|
||||
final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
||||
@@ -63,6 +64,8 @@ final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.send(.recoveryKey)
|
||||
case .skip:
|
||||
actionsSubject.send(.skip)
|
||||
case .reset:
|
||||
actionsSubject.send(.reset)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -21,15 +21,16 @@ enum IdentityConfirmationScreenViewModelAction {
|
||||
case recoveryKey
|
||||
/// Only possible in debug builds.
|
||||
case skip
|
||||
case reset
|
||||
}
|
||||
|
||||
struct IdentityConfirmationScreenViewState: BindableState {
|
||||
enum Mode {
|
||||
case recoveryOnly
|
||||
case recoveryAndVerification
|
||||
enum AvailableActions {
|
||||
case recovery
|
||||
case interactiveVerification
|
||||
}
|
||||
|
||||
var mode = Mode.recoveryOnly
|
||||
var availableActions: [AvailableActions] = []
|
||||
let learnMoreURL: URL
|
||||
}
|
||||
|
||||
@@ -38,4 +39,5 @@ enum IdentityConfirmationScreenViewAction {
|
||||
case recoveryKey
|
||||
/// Only possible in debug builds.
|
||||
case skip
|
||||
case reset
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy
|
||||
actionsSubject.send(.recoveryKey)
|
||||
case .skip:
|
||||
actionsSubject.send(.skip)
|
||||
case .reset:
|
||||
actionsSubject.send(.reset)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,11 +77,18 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy
|
||||
return
|
||||
}
|
||||
|
||||
guard case let .success(isOnlyDeviceLeft) = await userSession.clientProxy.isOnlyDeviceLeft() else {
|
||||
return
|
||||
var availableActions: [IdentityConfirmationScreenViewState.AvailableActions] = []
|
||||
|
||||
if case let .success(isOnlyDeviceLeft) = await userSession.clientProxy.isOnlyDeviceLeft(),
|
||||
!isOnlyDeviceLeft {
|
||||
availableActions.append(.interactiveVerification)
|
||||
}
|
||||
|
||||
state.mode = isOnlyDeviceLeft ? .recoveryOnly : .recoveryAndVerification
|
||||
if sessionSecurityState.recoveryState == .enabled || sessionSecurityState.recoveryState == .incomplete {
|
||||
availableActions.append(.recovery)
|
||||
}
|
||||
|
||||
state.availableActions = availableActions
|
||||
}
|
||||
|
||||
private static let loadingIndicatorIdentifier = "\(IdentityConfirmationScreenViewModel.self)-Loading"
|
||||
|
||||
@@ -71,23 +71,23 @@ struct IdentityConfirmationScreen: View {
|
||||
@ViewBuilder
|
||||
private var actionButtons: some View {
|
||||
VStack(spacing: 32) {
|
||||
switch context.viewState.mode {
|
||||
case .recoveryOnly:
|
||||
Button(L10n.screenSessionVerificationEnterRecoveryKey) {
|
||||
context.send(viewAction: .recoveryKey)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
|
||||
case .recoveryAndVerification:
|
||||
if context.viewState.availableActions.contains(.interactiveVerification) {
|
||||
Button(L10n.actionStartVerification) {
|
||||
context.send(viewAction: .otherDevice)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
|
||||
if context.viewState.availableActions.contains(.recovery) {
|
||||
Button(L10n.screenSessionVerificationEnterRecoveryKey) {
|
||||
context.send(viewAction: .recoveryKey)
|
||||
}
|
||||
.buttonStyle(.compound(.plain))
|
||||
}
|
||||
} else if context.viewState.availableActions.contains(.recovery) {
|
||||
Button(L10n.screenSessionVerificationEnterRecoveryKey) {
|
||||
context.send(viewAction: .recoveryKey)
|
||||
}
|
||||
.buttonStyle(.compound(.plain))
|
||||
.buttonStyle(.compound(.primary))
|
||||
}
|
||||
|
||||
if shouldShowSkipButton {
|
||||
@@ -96,6 +96,11 @@ struct IdentityConfirmationScreen: View {
|
||||
}
|
||||
.buttonStyle(.compound(.plain))
|
||||
}
|
||||
|
||||
Button(L10n.screenRecoveryKeyConfirmLostRecoveryKey, role: .destructive) {
|
||||
context.send(viewAction: .reset)
|
||||
}
|
||||
.buttonStyle(.compound(.plain))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f3ac13eb903ab6386f788382ea3362e6ef49f0aa065dd672953f1960bad44a27
|
||||
size 115060
|
||||
oid sha256:062da336508f1585f505f4cbb28885ba81f62082c8e786bd920386cc34d5ccea
|
||||
size 118392
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:783830e86a68a1aec227f6e16fc865451cdb3407e7b7967a00bf1d3920d8db92
|
||||
size 146800
|
||||
oid sha256:aed4dbdb22e4fa558b72f189a581e0930fc8d0476d7e0d7dcf9e1a8afb7d17a5
|
||||
size 156197
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:15e443ca166ca691ac1f7ba73732e564c5ea3e18297f290337d94fc55da1a821
|
||||
size 71486
|
||||
oid sha256:7049b155c4155acf845121595c828822d51143b72cb1cc0eb5fb8309a5ee1c7a
|
||||
size 75502
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f44459b131c9d4a9c88547b9b58c23814919fe2311ffac7694cf19e5f584e817
|
||||
size 106764
|
||||
oid sha256:055aa831d819235c1f49b158dd329f10bd8be99d2a8b470e7786b58527d3c168
|
||||
size 117727
|
||||
|
||||
Reference in New Issue
Block a user