Secure backup tweaks (#2095)

* Show a loading indicator when confirming the recovery key

* Hide the passphrase characters when confirming the recovery key

* Don't show the settings security section until session verification state is retrieved (async)

* Fix preview screenshots
This commit is contained in:
Stefan Ceriu
2023-11-17 12:06:36 +02:00
committed by GitHub
parent 22742620c5
commit d245a4f158
6 changed files with 14 additions and 9 deletions
@@ -72,6 +72,9 @@ class SecureBackupRecoveryKeyScreenViewModel: SecureBackupRecoveryKeyScreenViewM
state.doneButtonEnabled = true state.doneButtonEnabled = true
case .confirmKey: case .confirmKey:
Task { Task {
let loadingIndicatorIdentifier = "SecureBackupRecoveryKeyScreen"
userIndicatorController.submitIndicator(.init(id: loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading, persistent: true))
switch await secureBackupController.confirmRecoveryKey(state.bindings.confirmationRecoveryKey) { switch await secureBackupController.confirmRecoveryKey(state.bindings.confirmationRecoveryKey) {
case .success: case .success:
actionsSubject.send(.done(mode: context.viewState.mode)) actionsSubject.send(.done(mode: context.viewState.mode))
@@ -79,6 +82,8 @@ class SecureBackupRecoveryKeyScreenViewModel: SecureBackupRecoveryKeyScreenViewM
MXLog.error("Failed confirming recovery key with error: \(error)") MXLog.error("Failed confirming recovery key with error: \(error)")
state.bindings.alertInfo = .init(id: .init()) state.bindings.alertInfo = .init(id: .init())
} }
userIndicatorController.retractIndicatorWithId(loadingIndicatorIdentifier)
} }
case .cancel: case .cancel:
actionsSubject.send(.cancel) actionsSubject.send(.cancel)
@@ -179,7 +179,7 @@ struct SecureBackupRecoveryKeyScreen: View {
.foregroundColor(.compound.textPrimary) .foregroundColor(.compound.textPrimary)
.font(.compound.bodySM) .font(.compound.bodySM)
TextField(L10n.screenRecoveryKeyConfirmKeyPlaceholder, text: $context.confirmationRecoveryKey) SecureField(L10n.screenRecoveryKeyConfirmKeyPlaceholder, text: $context.confirmationRecoveryKey)
.textContentType(.password) // Not ideal but stops random suggestions .textContentType(.password) // Not ideal but stops random suggestions
.autocapitalization(.none) .autocapitalization(.none)
.disableAutocorrection(true) .disableAutocorrection(true)
@@ -41,7 +41,7 @@ struct SettingsScreenViewState: BindableState {
var accountSessionsListURL: URL? var accountSessionsListURL: URL?
var userAvatarURL: URL? var userAvatarURL: URL?
var userDisplayName: String? var userDisplayName: String?
var isSessionVerified = false var isSessionVerified: Bool?
var chatBackupEnabled = false var chatBackupEnabled = false
var showSecureBackupBadge = false var showSecureBackupBadge = false
var showDeveloperOptions: Bool var showDeveloperOptions: Bool
@@ -84,9 +84,9 @@ struct SettingsScreen: View {
@ViewBuilder @ViewBuilder
private var accountSecuritySection: some View { private var accountSecuritySection: some View {
if !context.viewState.isSessionVerified || context.viewState.chatBackupEnabled { Section {
Section { if let isSessionVerified = context.viewState.isSessionVerified {
if !context.viewState.isSessionVerified { if !isSessionVerified {
ListRow(label: .default(title: L10n.actionCompleteVerification, ListRow(label: .default(title: L10n.actionCompleteVerification,
icon: \.checkCircle), icon: \.checkCircle),
kind: .button { context.send(viewAction: .sessionVerification) }) kind: .button { context.send(viewAction: .sessionVerification) })
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:d008d9474ae107ca66f04a476377fdcc310ba5b8af127b6ee93469c67ec0f789 oid sha256:c1c8b8ebdb1abc2ed1be215b68a63000cd48d6d6ac2f7ff57824bb6536c30d81
size 106279 size 106300
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:895dd83310e0768ff726fb0b737272370700a87c7e1d12bf0588ed63f700b266 oid sha256:1fb0f5f22637712c94016f1eaebc9e1460a873dfe954df70fd555b6eaff1f131
size 175844 size 170780