From f3a15f793764a8cc4e3d99c1373483a949e878f4 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:52:51 +0000 Subject: [PATCH] Fix the Setup Recovery flow from the home screen banner. (#3483) --- .../Sources/FlowCoordinators/UserSessionFlowCoordinator.swift | 2 ++ .../Sources/Screens/HomeScreen/HomeScreenCoordinator.swift | 3 +++ ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift | 4 +++- ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift | 4 +++- .../View/HomeScreenRecoveryKeyConfirmationBanner.swift | 3 ++- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift index 42b6f782f..b824715d3 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift @@ -466,6 +466,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { settingsFlowCoordinator.handleAppRoute(.settings, animated: true) case .presentFeedbackScreen: stateMachine.processEvent(.feedbackScreen) + case .presentSecureBackupSettings: + settingsFlowCoordinator.handleAppRoute(.chatBackupSettings, animated: true) case .presentRecoveryKeyScreen: stateMachine.processEvent(.showRecoveryKeyScreen) case .presentEncryptionResetScreen: diff --git a/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift b/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift index 22753bc35..00f2476be 100644 --- a/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift +++ b/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift @@ -20,6 +20,7 @@ enum HomeScreenCoordinatorAction { case roomLeft(roomIdentifier: String) case presentSettingsScreen case presentFeedbackScreen + case presentSecureBackupSettings case presentRecoveryKeyScreen case presentEncryptionResetScreen case presentStartChatScreen @@ -64,6 +65,8 @@ final class HomeScreenCoordinator: CoordinatorProtocol { actionsSubject.send(.presentFeedbackScreen) case .presentSettingsScreen: actionsSubject.send(.presentSettingsScreen) + case .presentSecureBackupSettings: + actionsSubject.send(.presentSecureBackupSettings) case .presentRecoveryKeyScreen: actionsSubject.send(.presentRecoveryKeyScreen) case .presentEncryptionResetScreen: diff --git a/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift b/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift index f0860160c..2e58c17ae 100644 --- a/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift +++ b/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift @@ -13,6 +13,7 @@ enum HomeScreenViewModelAction { case presentRoom(roomIdentifier: String) case presentRoomDetails(roomIdentifier: String) case roomLeft(roomIdentifier: String) + case presentSecureBackupSettings case presentRecoveryKeyScreen case presentEncryptionResetScreen case presentSettingsScreen @@ -31,7 +32,8 @@ enum HomeScreenViewAction { case confirmLeaveRoom(roomIdentifier: String) case showSettings case startChat - case manageRecoveryKey + case setupRecovery + case confirmRecoveryKey case resetEncryption case skipRecoveryKeyConfirmation case confirmSlidingSyncUpgrade diff --git a/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift b/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift index 3c8a241a1..c1b21cf4f 100644 --- a/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift +++ b/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift @@ -138,7 +138,9 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol Task { await leaveRoom(roomID: roomIdentifier) } case .showSettings: actionsSubject.send(.presentSettingsScreen) - case .manageRecoveryKey: + case .setupRecovery: + actionsSubject.send(.presentSecureBackupSettings) + case .confirmRecoveryKey: actionsSubject.send(.presentRecoveryKeyScreen) case .resetEncryption: actionsSubject.send(.presentEncryptionResetScreen) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift index 3f4919eee..1adf1fac7 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift @@ -16,6 +16,7 @@ struct HomeScreenRecoveryKeyConfirmationBanner: View { var title: String { requiresExtraAccountSetup ? L10n.bannerSetUpRecoveryTitle : L10n.confirmRecoveryKeyBannerTitle } var message: String { requiresExtraAccountSetup ? L10n.bannerSetUpRecoveryContent : L10n.confirmRecoveryKeyBannerMessage } var actionTitle: String { requiresExtraAccountSetup ? L10n.bannerSetUpRecoverySubmit : L10n.confirmRecoveryKeyBannerPrimaryButtonTitle } + var primaryAction: HomeScreenViewAction { requiresExtraAccountSetup ? .setupRecovery : .confirmRecoveryKey } var body: some View { VStack(spacing: 16) { @@ -56,7 +57,7 @@ struct HomeScreenRecoveryKeyConfirmationBanner: View { var buttons: some View { VStack(spacing: 16) { Button(actionTitle) { - context.send(viewAction: .manageRecoveryKey) + context.send(viewAction: primaryAction) } .frame(maxWidth: .infinity) .buttonStyle(.compound(.primary, size: .medium))