mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add support for account deactivation when not using OIDC. (#3295)
This commit is contained in:
@@ -27,6 +27,7 @@ enum SettingsScreenCoordinatorAction {
|
||||
case notifications
|
||||
case advancedSettings
|
||||
case developerOptions
|
||||
case deactivateAccount
|
||||
}
|
||||
|
||||
final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
@@ -75,6 +76,8 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.send(.developerOptions)
|
||||
case .logout:
|
||||
actionsSubject.send(.logout)
|
||||
case .deactivateAccount:
|
||||
actionsSubject.send(.deactivateAccount)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -22,6 +22,7 @@ enum SettingsScreenViewModelAction: Equatable {
|
||||
case advancedSettings
|
||||
case developerOptions
|
||||
case logout
|
||||
case deactivateAccount
|
||||
}
|
||||
|
||||
enum SettingsScreenSecuritySectionMode {
|
||||
@@ -34,6 +35,7 @@ struct SettingsScreenViewState: BindableState {
|
||||
var userID: String
|
||||
var accountProfileURL: URL?
|
||||
var accountSessionsListURL: URL?
|
||||
var showAccountDeactivation: Bool
|
||||
var userAvatarURL: URL?
|
||||
var userDisplayName: String?
|
||||
var showDeveloperOptions: Bool
|
||||
@@ -42,6 +44,12 @@ struct SettingsScreenViewState: BindableState {
|
||||
var showSecuritySectionBadge = false
|
||||
|
||||
var showBlockedUsers = false
|
||||
|
||||
var bindings = SettingsScreenViewStateBindings()
|
||||
}
|
||||
|
||||
struct SettingsScreenViewStateBindings {
|
||||
var isPresentingAccountDeactivationConfirmation = false
|
||||
}
|
||||
|
||||
enum SettingsScreenViewAction {
|
||||
@@ -59,4 +67,5 @@ enum SettingsScreenViewAction {
|
||||
case developerOptions
|
||||
case advancedSettings
|
||||
case logout
|
||||
case deactivateAccount
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
init(userSession: UserSessionProtocol) {
|
||||
super.init(initialViewState: .init(deviceID: userSession.clientProxy.deviceID,
|
||||
userID: userSession.clientProxy.userID,
|
||||
showAccountDeactivation: userSession.clientProxy.canDeactivateAccount,
|
||||
showDeveloperOptions: AppSettings.isDevelopmentBuild),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
@@ -105,6 +106,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
state.showDeveloperOptions = true
|
||||
case .developerOptions:
|
||||
actionsSubject.send(.developerOptions)
|
||||
case .deactivateAccount:
|
||||
actionsSubject.send(.deactivateAccount)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ struct SettingsScreen: View {
|
||||
}
|
||||
|
||||
generalSection
|
||||
|
||||
signOutSection
|
||||
}
|
||||
.compoundList()
|
||||
.navigationTitle(L10n.commonSettings)
|
||||
@@ -167,7 +169,11 @@ struct SettingsScreen: View {
|
||||
})
|
||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.developerOptions)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private var signOutSection: some View {
|
||||
Section {
|
||||
ListRow(label: .action(title: L10n.screenSignoutPreferenceItem,
|
||||
icon: \.signOut,
|
||||
role: .destructive),
|
||||
@@ -175,6 +181,14 @@ 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 {
|
||||
context.send(viewAction: .deactivateAccount)
|
||||
})
|
||||
}
|
||||
} footer: {
|
||||
VStack(spacing: 0) {
|
||||
versionText
|
||||
|
||||
Reference in New Issue
Block a user