Account deletion fixes

This commit is contained in:
Ilya Laktyushin 2022-07-04 15:49:09 +03:00
parent 06b9ea8089
commit ed2585a337

View File

@ -462,12 +462,13 @@ func deleteAccountDataController(context: AccountContext, mode: DeleteAccountDat
return updated return updated
} }
secondaryActionDisabled = false
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})])) presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]))
}, completed: { }, completed: {
dismissImpl?() dismissImpl?()
let presentGlobalController = context.sharedContext.presentGlobalController let presentGlobalController = context.sharedContext.presentGlobalController
let _ = logoutFromAccount(id: accountId, accountManager: accountManager, alreadyLoggedOutRemotely: true).start(completed: { let _ = logoutFromAccount(id: accountId, accountManager: accountManager, alreadyLoggedOutRemotely: false).start(completed: {
Queue.mainQueue().after(0.1) { Queue.mainQueue().after(0.1) {
presentGlobalController(UndoOverlayController(presentationData: presentationData, content: .info(title: nil, text: presentationData.strings.DeleteAccount_Success), elevatedLayout: true, animateInAsReplacement: false, action: { _ in return false }), nil) presentGlobalController(UndoOverlayController(presentationData: presentationData, content: .info(title: nil, text: presentationData.strings.DeleteAccount_Success), elevatedLayout: true, animateInAsReplacement: false, action: { _ in return false }), nil)
} }
@ -492,7 +493,11 @@ func deleteAccountDataController(context: AccountContext, mode: DeleteAccountDat
var phoneNumber: String? var phoneNumber: String?
controller?.forEachItemNode { itemNode in controller?.forEachItemNode { itemNode in
if let itemNode = itemNode as? DeleteAccountPhoneItemNode { if let itemNode = itemNode as? DeleteAccountPhoneItemNode {
phoneNumber = itemNode.phoneNumber var phoneValue = itemNode.phoneNumber
if phoneValue.hasPrefix("+939998") {
phoneValue = phoneValue.replacingOccurrences(of: "+939998", with: "+9998")
}
phoneNumber = phoneValue
} }
} }
@ -505,6 +510,7 @@ func deleteAccountDataController(context: AccountContext, mode: DeleteAccountDat
phone = "+\(phone)" phone = "+\(phone)"
} }
if phone != phoneNumber { if phone != phoneNumber {
secondaryActionDisabled = false
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.DeleteAccount_InvalidPhoneNumberError, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})])) presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.DeleteAccount_InvalidPhoneNumberError, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]))
return return
} }
@ -523,6 +529,8 @@ func deleteAccountDataController(context: AccountContext, mode: DeleteAccountDat
let _ = (context.engine.auth.requestTwoStepVerifiationSettings(password: state.password) let _ = (context.engine.auth.requestTwoStepVerifiationSettings(password: state.password)
|> deliverOnMainQueue).start(error: { error in |> deliverOnMainQueue).start(error: { error in
secondaryActionDisabled = false
updateState { current in updateState { current in
var updated = current var updated = current
updated.isLoading = false updated.isLoading = false