diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenSettingsActions.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenSettingsActions.swift index 75f5124a37..38e0b7dc76 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenSettingsActions.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenSettingsActions.swift @@ -1,3 +1,4 @@ +import SGStrings import SGSettingsUI import Foundation import UIKit @@ -231,15 +232,15 @@ extension PeerInfoScreenNode { guard let strongSelf = self else { return } - var maximumAvailableAccounts: Int = 3 + var maximumAvailableAccounts: Int = maximumSwiftgramNumberOfAccounts if accountAndPeer?.1.isPremium == true && !strongSelf.context.account.testingEnvironment { - maximumAvailableAccounts = 4 + maximumAvailableAccounts = maximumSwiftgramNumberOfAccounts } var count: Int = 1 for (accountContext, peer, _) in accountsAndPeers { if !accountContext.account.testingEnvironment { if peer.isPremium { - maximumAvailableAccounts = 4 + maximumAvailableAccounts = maximumSwiftgramNumberOfAccounts } count += 1 } @@ -259,7 +260,23 @@ extension PeerInfoScreenNode { navigationController.pushViewController(controller) } } else { - strongSelf.context.sharedContext.beginNewAuth(testingEnvironment: strongSelf.context.account.testingEnvironment) + // MARK: Swiftgram + if count + 1 > maximumSafeNumberOfAccounts { + let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } + let alertController = textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.controller?.updatedPresentationData, title: presentationData.strings.ChatList_DeleteSavedMessagesConfirmationTitle, text: i18n("Auth.AccountBackupReminder", presentationData.strings.baseLanguageCode), actions: [ + TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: { + strongSelf.context.sharedContext.beginNewAuth(testingEnvironment: strongSelf.context.account.testingEnvironment) + }) + ]) + if let controller = strongSelf.controller { + controller.present(alertController, in: .window(.root)) + } else { + strongSelf.context.sharedContext.beginNewAuth(testingEnvironment: strongSelf.context.account.testingEnvironment) + } + } else { + strongSelf.context.sharedContext.beginNewAuth(testingEnvironment: strongSelf.context.account.testingEnvironment) + } + // } }) case .logout: