Push the deactivate account screen. (#3297)

This commit is contained in:
Doug
2024-09-18 10:21:48 +01:00
committed by GitHub
parent 5625e78fc9
commit 5078f571ed
11 changed files with 11 additions and 41 deletions
@@ -242,8 +242,6 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
}
private func presentDeactivateAccount() {
let navigationCoordinator = NavigationStackCoordinator()
let parameters = DeactivateAccountScreenCoordinatorParameters(clientProxy: parameters.userSession.clientProxy,
userIndicatorController: parameters.userIndicatorController)
let coordinator = DeactivateAccountScreenCoordinator(parameters: parameters)
@@ -253,16 +251,13 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
guard let self else { return }
switch action {
case .cancel:
navigationStackCoordinator.setSheetCoordinator(nil)
case .accountDeactivated:
actionsSubject.send(.forceLogout)
}
}
.store(in: &cancellables)
navigationCoordinator.setRootCoordinator(coordinator)
navigationStackCoordinator.setSheetCoordinator(navigationCoordinator)
navigationStackCoordinator.push(coordinator)
}
// MARK: OIDC Account Management
@@ -14,7 +14,6 @@ struct DeactivateAccountScreenCoordinatorParameters {
}
enum DeactivateAccountScreenCoordinatorAction {
case cancel
case accountDeactivated
}
@@ -42,8 +41,6 @@ final class DeactivateAccountScreenCoordinator: CoordinatorProtocol {
guard let self else { return }
switch action {
case .cancel:
actionsSubject.send(.cancel)
case .accountDeactivated:
actionsSubject.send(.accountDeactivated)
}
@@ -8,7 +8,6 @@
import Foundation
enum DeactivateAccountScreenViewModelAction {
case cancel
case accountDeactivated
}
@@ -50,5 +49,4 @@ enum DeactivateAccountScreenAlert {
enum DeactivateAccountScreenViewAction {
case deactivate
case cancel
}
@@ -30,8 +30,6 @@ class DeactivateAccountScreenViewModel: DeactivateAccountScreenViewModelType, De
MXLog.info("View model: received view action: \(viewAction)")
switch viewAction {
case .cancel:
actionsSubject.send(.cancel)
case .deactivate:
showDeactivationConfirmation()
}
@@ -29,7 +29,6 @@ struct DeactivateAccountScreen: View {
}
.navigationTitle(L10n.screenDeactivateAccountTitle)
.navigationBarTitleDisplayMode(.inline)
.toolbar { toolbar }
.alert(item: $context.alertInfo)
}
@@ -71,14 +70,6 @@ struct DeactivateAccountScreen: View {
.compoundListSectionHeader()
}
}
private var toolbar: some ToolbarContent {
ToolbarItem(placement: .cancellationAction) {
Button(L10n.actionCancel) {
context.send(viewAction: .cancel)
}
}
}
}
private struct InfoItem: View {
@@ -181,11 +181,12 @@ struct SettingsScreen: View {
context.send(viewAction: .logout)
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.logout)
if context.viewState.showAccountDeactivation {
ListRow(label: .action(title: L10n.actionDeactivateAccount,
icon: \.warning,
role: .destructive),
kind: .button {
kind: .navigationLink {
context.send(viewAction: .deactivateAccount)
})
}
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:49a19ce44c0cc157d621ad1d5067e9f0437646804778dae6b7090dac2a8d0cbe
size 168006
oid sha256:f7810a4ae8150a5faa1a92d0cf58a5ea8abcb64d870660a7bbd4c8b3c6f3c51b
size 165278
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f92b9a6497e4b1262ff279021ced2787d662e243e85e1a11d43e36d495cab9c8
size 214697
oid sha256:90bdaeae27c7f49ad5d99334cebb933a03fa61cd415a2a0bbe16b30e388ca11d
size 212159
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:edd11721586663568ff973660f16fcff783dabba4bf5a2805caa0aa956ec2fd7
size 124025
oid sha256:9bce17faedcffc9205b7d64950e249f2400f488d971d6053c994a835d22bfcf5
size 121819
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0f4b0057cb0a667fee987afdad9fe1bf2bc4ee3455e2e87f1a5eac98d51be364
size 192025
oid sha256:f8d40ed55df8eaa86ba73d1d1a244a5cff097c15b310519f61a54058d556581d
size 189910
@@ -78,14 +78,4 @@ class DeactivateAccountScreenViewModelTests: XCTestCase {
XCTAssertEqual(clientProxy.deactivateAccountPasswordEraseDataReceivedArguments?.password, enteredPassword)
XCTAssertEqual(clientProxy.deactivateAccountPasswordEraseDataReceivedArguments?.eraseData, shouldErase)
}
func testCancel() async throws {
// When cancelling the view.
let deferred = deferFulfillment(viewModel.actionsPublisher) { $0 == .cancel }
context.send(viewAction: .cancel)
try await deferred.fulfill()
// Then no API call should be made to deactivate the account.
XCTAssertFalse(clientProxy.deactivateAccountPasswordEraseDataCalled)
}
}