Skip to content

Commit

Permalink
Push the deactivate account screen. (#3297)
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave authored Sep 18, 2024
1 parent 5625e78 commit 5078f57
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ struct DeactivateAccountScreenCoordinatorParameters {
}

enum DeactivateAccountScreenCoordinatorAction {
case cancel
case accountDeactivated
}

Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation

enum DeactivateAccountScreenViewModelAction {
case cancel
case accountDeactivated
}

Expand Down Expand Up @@ -50,5 +49,4 @@ enum DeactivateAccountScreenAlert {

enum DeactivateAccountScreenViewAction {
case deactivate
case cancel
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct DeactivateAccountScreen: View {
}
.navigationTitle(L10n.screenDeactivateAccountTitle)
.navigationBarTitleDisplayMode(.inline)
.toolbar { toolbar }
.alert(item: $context.alertInfo)
}

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 0 additions & 10 deletions UnitTests/Sources/DeactivateAccountScreenViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 5078f57

Please sign in to comment.