Add app outdated error

This commit is contained in:
Ali 2023-04-25 21:25:48 +04:00
parent 123059842a
commit 1037b25bc5
3 changed files with 26 additions and 1 deletions

View File

@ -9343,3 +9343,5 @@ Sorry for the inconvenience.";
"ChatList.PremiumRestoreDiscountTitle" = "Get Premium back with up to %@ off";
"ChatList.PremiumRestoreDiscountText" = "Your Telegram Premium has recently expired. Tap here to extend it.";
"Login.ErrorAppOutdated" = "Please update Telegram to the latest version to log in.";

View File

@ -221,6 +221,13 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
case .phoneLimitExceeded:
text = strongSelf.presentationData.strings.Login_PhoneFloodError
actions.append(TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {}))
case .appOutdated:
text = strongSelf.presentationData.strings.Login_ErrorAppOutdated
let updateUrl = strongSelf.presentationData.strings.InviteText_URL
let sharedContext = strongSelf.sharedContext
actions.append(TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {
sharedContext.applicationBindings.openUrl(updateUrl)
}))
case .phoneBanned:
text = strongSelf.presentationData.strings.Login_PhoneBannedError
actions.append(TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_OK, action: {}))
@ -581,6 +588,8 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
if let strongSelf = self, let controller = controller {
controller.inProgress = false
var actions: [TextAlertAction] = [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]
let text: String
switch error {
case .limitExceeded:
@ -589,6 +598,13 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
text = strongSelf.presentationData.strings.Login_InvalidPhoneError
case .phoneLimitExceeded:
text = strongSelf.presentationData.strings.Login_PhoneFloodError
case .appOutdated:
text = strongSelf.presentationData.strings.Login_ErrorAppOutdated
let updateUrl = strongSelf.presentationData.strings.InviteText_URL
let sharedContext = strongSelf.sharedContext
actions = [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {
sharedContext.applicationBindings.openUrl(updateUrl)
})]
case .phoneBanned:
text = strongSelf.presentationData.strings.Login_PhoneBannedError
case .generic:
@ -597,7 +613,7 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
text = strongSelf.presentationData.strings.Login_NetworkError
}
controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: text, actions: actions), in: .window(.root))
}
}))
}

View File

@ -12,6 +12,7 @@ public enum AuthorizationCodeRequestError {
case phoneLimitExceeded
case phoneBanned
case timeout
case appOutdated
}
func switchToAuthorizedAccount(transaction: AccountManagerModifier<TelegramAccountManagerTypes>, account: UnauthorizedAccount) {
@ -230,6 +231,8 @@ public func sendAuthorizationCode(accountManager: AccountManager<TelegramAccount
return .fail(.phoneLimitExceeded)
} else if error.errorDescription == "PHONE_NUMBER_BANNED" {
return .fail(.phoneBanned)
} else if error.errorDescription == "UPDATE_APP_TO_LOGIN" {
return .fail(.appOutdated)
} else if error.errorDescription == "SESSION_PASSWORD_NEEDED" {
return account.network.request(Api.functions.account.getPassword(), automaticFloodWait: false)
|> mapError { error -> AuthorizationCodeRequestError in
@ -356,6 +359,8 @@ private func internalResendAuthorizationCode(accountManager: AccountManager<Tele
return .phoneLimitExceeded
} else if error.errorDescription == "PHONE_NUMBER_BANNED" {
return .phoneBanned
} else if error.errorDescription == "UPDATE_APP_TO_LOGIN" {
return .appOutdated
} else {
return .generic(info: (Int(error.errorCode), error.errorDescription))
}
@ -442,6 +447,8 @@ public func resendAuthorizationCode(accountManager: AccountManager<TelegramAccou
return .phoneLimitExceeded
} else if error.errorDescription == "PHONE_NUMBER_BANNED" {
return .phoneBanned
} else if error.errorDescription == "UPDATE_APP_TO_LOGIN" {
return .appOutdated
} else {
return .generic(info: (Int(error.errorCode), error.errorDescription))
}