mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Show recovery instead of verification if this is the last session and recovery is set up
* Show recovery instead of verification if this is the last session and recovery is set up * Rename `recoveryKeyState` to `recoveryState` * Remove duplicates on session security state changes. * Fix missing "Save recovery key" button * Fix unit tests * Rename `isLastDevice` to `isOnlyDeviceLeft` * Address PR comments
This commit is contained in:
+19
-13
@@ -65,6 +65,20 @@ struct SecureBackupRecoveryKeyScreen: View {
|
||||
private var footer: some View {
|
||||
switch context.viewState.mode {
|
||||
case .setupRecovery, .changeRecovery:
|
||||
recoveryCreatedActionButtons
|
||||
case .fixRecovery:
|
||||
Button {
|
||||
context.send(viewAction: .confirmKey)
|
||||
} label: {
|
||||
Text(L10n.actionConfirm)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
.disabled(context.confirmationRecoveryKey.isEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
private var recoveryCreatedActionButtons: some View {
|
||||
VStack(spacing: 8.0) {
|
||||
if let recoveryKey = context.viewState.recoveryKey {
|
||||
ShareLink(item: recoveryKey) {
|
||||
Label(L10n.screenRecoveryKeySaveAction, icon: \.download)
|
||||
@@ -82,14 +96,6 @@ struct SecureBackupRecoveryKeyScreen: View {
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
.disabled(context.viewState.recoveryKey == nil || context.viewState.doneButtonEnabled == false)
|
||||
case .fixRecovery:
|
||||
Button {
|
||||
context.send(viewAction: .confirmKey)
|
||||
} label: {
|
||||
Text(L10n.actionConfirm)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
.disabled(context.confirmationRecoveryKey.isEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,9 +210,9 @@ struct SecureBackupRecoveryKeyScreen: View {
|
||||
// MARK: - Previews
|
||||
|
||||
struct SecureBackupRecoveryKeyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let setupViewModel = viewModel(recoveryKeyState: .enabled)
|
||||
static let notSetUpViewModel = viewModel(recoveryKeyState: .disabled)
|
||||
static let incompleteViewModel = viewModel(recoveryKeyState: .incomplete)
|
||||
static let setupViewModel = viewModel(recoveryState: .enabled)
|
||||
static let notSetUpViewModel = viewModel(recoveryState: .disabled)
|
||||
static let incompleteViewModel = viewModel(recoveryState: .incomplete)
|
||||
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
@@ -225,9 +231,9 @@ struct SecureBackupRecoveryKeyScreen_Previews: PreviewProvider, TestablePreview
|
||||
.previewDisplayName("Incomplete")
|
||||
}
|
||||
|
||||
static func viewModel(recoveryKeyState: SecureBackupRecoveryKeyState) -> SecureBackupRecoveryKeyScreenViewModelType {
|
||||
static func viewModel(recoveryState: SecureBackupRecoveryState) -> SecureBackupRecoveryKeyScreenViewModelType {
|
||||
let backupController = SecureBackupControllerMock()
|
||||
backupController.underlyingRecoveryKeyState = CurrentValueSubject<SecureBackupRecoveryKeyState, Never>(recoveryKeyState).asCurrentValuePublisher()
|
||||
backupController.underlyingRecoveryState = CurrentValueSubject<SecureBackupRecoveryState, Never>(recoveryState).asCurrentValuePublisher()
|
||||
|
||||
return SecureBackupRecoveryKeyScreenViewModel(secureBackupController: backupController, userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user