Key backup Rust API adoption (#1952)

* Adopt Rust side secure backup APIs (incomplete, based on poljar/backup-pr)

* Implement the home screen recovery key confirmation banner.

* Update with the latest Rust changes.

The loading button for .unknown was incorrect. It should be treated as disabled.

---------

Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
Stefan Ceriu
2023-10-27 22:16:51 +03:00
committed by GitHub
parent 4077f5f4bb
commit a837ce5cff
22 changed files with 444 additions and 166 deletions
@@ -64,7 +64,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
// The navigation stack doesn't like it if the root and the push happen
// on the same loop run
DispatchQueue.main.async {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
self.presentSecureBackupScreen(animated: animated)
}
default:
@@ -115,7 +115,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
case .dismissedSettings:
stateMachine.processEvent(.dismissedSettingsScreen)
case .runLogoutFlow:
runLogoutFlow()
Task { await self.runLogoutFlow() }
case .clearCache:
actionsSubject.send(.clearCache)
case .forceLogout:
@@ -330,10 +330,12 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.processEvent(.feedbackScreen)
case .presentSessionVerificationScreen:
stateMachine.processEvent(.showSessionVerificationScreen)
case .presentSecureBackupSettings:
settingsFlowCoordinator.handleAppRoute(.chatBackupSettings, animated: true)
case .presentStartChatScreen:
stateMachine.processEvent(.showStartChatScreen)
case .logout:
runLogoutFlow()
Task { await self.runLogoutFlow() }
case .presentInvitesScreen:
stateMachine.processEvent(.showInvitesScreen)
}
@@ -358,10 +360,15 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
}
}
private func runLogoutFlow() {
private func runLogoutFlow() async {
let secureBackupController = userSession.clientProxy.secureBackupController
guard secureBackupController.isLastSession, appSettings.chatBackupEnabled else {
guard case let .success(isLastSession) = await secureBackupController.isLastSession() else {
ServiceLocator.shared.userIndicatorController.alertInfo = .init(id: .init())
return
}
guard isLastSession, appSettings.chatBackupEnabled else {
ServiceLocator.shared.userIndicatorController.alertInfo = .init(id: .init(),
title: L10n.screenSignoutRecoveryDisabledTitle,
message: L10n.screenSignoutRecoveryDisabledSubtitle,