mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-06 20:38:41 +00:00
Push the deactivate account screen. (#3297)
This commit is contained in:
@@ -242,8 +242,6 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func presentDeactivateAccount() {
|
private func presentDeactivateAccount() {
|
||||||
let navigationCoordinator = NavigationStackCoordinator()
|
|
||||||
|
|
||||||
let parameters = DeactivateAccountScreenCoordinatorParameters(clientProxy: parameters.userSession.clientProxy,
|
let parameters = DeactivateAccountScreenCoordinatorParameters(clientProxy: parameters.userSession.clientProxy,
|
||||||
userIndicatorController: parameters.userIndicatorController)
|
userIndicatorController: parameters.userIndicatorController)
|
||||||
let coordinator = DeactivateAccountScreenCoordinator(parameters: parameters)
|
let coordinator = DeactivateAccountScreenCoordinator(parameters: parameters)
|
||||||
@@ -253,16 +251,13 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
case .cancel:
|
|
||||||
navigationStackCoordinator.setSheetCoordinator(nil)
|
|
||||||
case .accountDeactivated:
|
case .accountDeactivated:
|
||||||
actionsSubject.send(.forceLogout)
|
actionsSubject.send(.forceLogout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
navigationCoordinator.setRootCoordinator(coordinator)
|
navigationStackCoordinator.push(coordinator)
|
||||||
navigationStackCoordinator.setSheetCoordinator(navigationCoordinator)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: OIDC Account Management
|
// MARK: OIDC Account Management
|
||||||
|
|||||||
-3
@@ -14,7 +14,6 @@ struct DeactivateAccountScreenCoordinatorParameters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum DeactivateAccountScreenCoordinatorAction {
|
enum DeactivateAccountScreenCoordinatorAction {
|
||||||
case cancel
|
|
||||||
case accountDeactivated
|
case accountDeactivated
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,8 +41,6 @@ final class DeactivateAccountScreenCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
switch action {
|
switch action {
|
||||||
case .cancel:
|
|
||||||
actionsSubject.send(.cancel)
|
|
||||||
case .accountDeactivated:
|
case .accountDeactivated:
|
||||||
actionsSubject.send(.accountDeactivated)
|
actionsSubject.send(.accountDeactivated)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum DeactivateAccountScreenViewModelAction {
|
enum DeactivateAccountScreenViewModelAction {
|
||||||
case cancel
|
|
||||||
case accountDeactivated
|
case accountDeactivated
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,5 +49,4 @@ enum DeactivateAccountScreenAlert {
|
|||||||
|
|
||||||
enum DeactivateAccountScreenViewAction {
|
enum DeactivateAccountScreenViewAction {
|
||||||
case deactivate
|
case deactivate
|
||||||
case cancel
|
|
||||||
}
|
}
|
||||||
|
|||||||
-2
@@ -30,8 +30,6 @@ class DeactivateAccountScreenViewModel: DeactivateAccountScreenViewModelType, De
|
|||||||
MXLog.info("View model: received view action: \(viewAction)")
|
MXLog.info("View model: received view action: \(viewAction)")
|
||||||
|
|
||||||
switch viewAction {
|
switch viewAction {
|
||||||
case .cancel:
|
|
||||||
actionsSubject.send(.cancel)
|
|
||||||
case .deactivate:
|
case .deactivate:
|
||||||
showDeactivationConfirmation()
|
showDeactivationConfirmation()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ struct DeactivateAccountScreen: View {
|
|||||||
}
|
}
|
||||||
.navigationTitle(L10n.screenDeactivateAccountTitle)
|
.navigationTitle(L10n.screenDeactivateAccountTitle)
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.toolbar { toolbar }
|
|
||||||
.alert(item: $context.alertInfo)
|
.alert(item: $context.alertInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,14 +70,6 @@ struct DeactivateAccountScreen: View {
|
|||||||
.compoundListSectionHeader()
|
.compoundListSectionHeader()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var toolbar: some ToolbarContent {
|
|
||||||
ToolbarItem(placement: .cancellationAction) {
|
|
||||||
Button(L10n.actionCancel) {
|
|
||||||
context.send(viewAction: .cancel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct InfoItem: View {
|
private struct InfoItem: View {
|
||||||
|
|||||||
@@ -181,11 +181,12 @@ struct SettingsScreen: View {
|
|||||||
context.send(viewAction: .logout)
|
context.send(viewAction: .logout)
|
||||||
})
|
})
|
||||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.logout)
|
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.logout)
|
||||||
|
|
||||||
if context.viewState.showAccountDeactivation {
|
if context.viewState.showAccountDeactivation {
|
||||||
ListRow(label: .action(title: L10n.actionDeactivateAccount,
|
ListRow(label: .action(title: L10n.actionDeactivateAccount,
|
||||||
icon: \.warning,
|
icon: \.warning,
|
||||||
role: .destructive),
|
role: .destructive),
|
||||||
kind: .button {
|
kind: .navigationLink {
|
||||||
context.send(viewAction: .deactivateAccount)
|
context.send(viewAction: .deactivateAccount)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:49a19ce44c0cc157d621ad1d5067e9f0437646804778dae6b7090dac2a8d0cbe
|
oid sha256:f7810a4ae8150a5faa1a92d0cf58a5ea8abcb64d870660a7bbd4c8b3c6f3c51b
|
||||||
size 168006
|
size 165278
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:f92b9a6497e4b1262ff279021ced2787d662e243e85e1a11d43e36d495cab9c8
|
oid sha256:90bdaeae27c7f49ad5d99334cebb933a03fa61cd415a2a0bbe16b30e388ca11d
|
||||||
size 214697
|
size 212159
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:edd11721586663568ff973660f16fcff783dabba4bf5a2805caa0aa956ec2fd7
|
oid sha256:9bce17faedcffc9205b7d64950e249f2400f488d971d6053c994a835d22bfcf5
|
||||||
size 124025
|
size 121819
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:0f4b0057cb0a667fee987afdad9fe1bf2bc4ee3455e2e87f1a5eac98d51be364
|
oid sha256:f8d40ed55df8eaa86ba73d1d1a244a5cff097c15b310519f61a54058d556581d
|
||||||
size 192025
|
size 189910
|
||||||
|
|||||||
@@ -78,14 +78,4 @@ class DeactivateAccountScreenViewModelTests: XCTestCase {
|
|||||||
XCTAssertEqual(clientProxy.deactivateAccountPasswordEraseDataReceivedArguments?.password, enteredPassword)
|
XCTAssertEqual(clientProxy.deactivateAccountPasswordEraseDataReceivedArguments?.password, enteredPassword)
|
||||||
XCTAssertEqual(clientProxy.deactivateAccountPasswordEraseDataReceivedArguments?.eraseData, shouldErase)
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user