MESSENGER-4951 Changed password confirmation

This commit is contained in:
Arnfried Griesert
2023-09-15 12:13:19 +00:00
parent fc3c125c4c
commit 099b861a8d
7 changed files with 35 additions and 12 deletions
@@ -49,19 +49,25 @@ class ChangePasswordViewModel: ChangePasswordViewModelType, ChangePasswordViewMo
switch viewAction {
case .submit:
guard state.bindings.newPassword1 == state.bindings.newPassword2 else {
Task { await displayError(.passwordsDontMatch) }
Task { await displayError(.passwordsDontMatch, primaryButtonCallback: {}) }
return
}
Task { await callback?(.submit(oldPassword: state.bindings.oldPassword,
newPassword: state.bindings.newPassword1,
signoutAllDevices: state.bindings.signoutAllDevices)) }
signoutAllDevices: state.bindings.signoutAllDevices))
}
case .toggleSignoutAllDevices:
state.bindings.signoutAllDevices.toggle()
}
}
@MainActor func displayError(_ type: ChangePasswordErrorType) {
@MainActor func displayError(_ type: ChangePasswordErrorType, primaryButtonCallback: @escaping (() -> Void)) {
switch type {
case .passwordChangeSucceeded:
state.bindings.alertInfo = AlertInfo(id: .passwordChangeSucceeded,
title: BWIL10n.settingsPasswordChanged,
message: "",
primaryButton: (VectorL10n.ok, action: { primaryButtonCallback() }))
case .mxError(let message):
state.bindings.alertInfo = AlertInfo(id: type,
title: VectorL10n.error,