diff --git a/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenViewModel.swift b/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenViewModel.swift index cd0b1d9dc..24c98fdc0 100644 --- a/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenViewModel.swift +++ b/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenViewModel.swift @@ -55,7 +55,7 @@ class SecureBackupScreenViewModel: SecureBackupScreenViewModelType, SecureBackup switch (keyBackupState, enable) { case (.unknown, true): state.bindings.keyStorageEnabled = keyBackupState.keyStorageToggleState // Reset the toggle in case enabling fails - enableBackup() + Task { await enableBackup() } case (.enabled, false): state.bindings.keyStorageEnabled = keyBackupState.keyStorageToggleState // Reset the toggle in case the user cancels actionsSubject.send(.disableKeyBackup) @@ -67,20 +67,18 @@ class SecureBackupScreenViewModel: SecureBackupScreenViewModelType, SecureBackup // MARK: - Private - private func enableBackup() { - Task { - let loadingIndicatorIdentifier = "SecureBackupScreenLoading" - userIndicatorController.submitIndicator(.init(id: loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading, persistent: true)) - switch await secureBackupController.enable() { - case .success: - break - case .failure(let error): - MXLog.error("Failed enabling key backup with error: \(error)") - state.bindings.alertInfo = .init(id: .init()) - } - - userIndicatorController.retractIndicatorWithId(loadingIndicatorIdentifier) + private func enableBackup() async { + let loadingIndicatorIdentifier = "SecureBackupScreenLoading" + userIndicatorController.submitIndicator(.init(id: loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading, persistent: true)) + switch await secureBackupController.enable() { + case .success: + break + case .failure(let error): + MXLog.error("Failed enabling key backup with error: \(error)") + state.bindings.alertInfo = .init(id: .init()) } + + userIndicatorController.retractIndicatorWithId(loadingIndicatorIdentifier) } } diff --git a/UITests/Sources/EncryptionSettingsTests.swift b/UITests/Sources/EncryptionSettingsTests.swift index b2e2a8278..5f6949c53 100644 --- a/UITests/Sources/EncryptionSettingsTests.swift +++ b/UITests/Sources/EncryptionSettingsTests.swift @@ -34,7 +34,8 @@ class EncryptionSettingsUITests: XCTestCase { // Broken by https://github.com/element-hq/compound-ios/pull/140 app.switches[A11yIdentifiers.secureBackupScreen.keyStorage].switches.firstMatch.tap() - try await app.assertScreenshot(step: Step.keyBackupScreen) + // Has been failing often on CI, reasons unclear. + try await app.assertScreenshot(step: Step.keyBackupScreen, delay: .seconds(1)) // Confirm deletion of keys. app.buttons[A11yIdentifiers.secureBackupKeyBackupScreen.deleteKeyStorage].tap()