mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Various improvements
This commit is contained in:
@@ -13,6 +13,8 @@ import AccountContext
|
||||
import AlertUI
|
||||
import PresentationDataUtils
|
||||
import UrlHandling
|
||||
import AccountUtils
|
||||
import PremiumUI
|
||||
|
||||
private struct LogoutOptionsItemArguments {
|
||||
let addAccount: () -> Void
|
||||
@@ -133,10 +135,38 @@ public func logoutOptionsController(context: AccountContext, navigationControlle
|
||||
let supportPeerDisposable = MetaDisposable()
|
||||
|
||||
let arguments = LogoutOptionsItemArguments(addAccount: {
|
||||
let isTestingEnvironment = context.account.testingEnvironment
|
||||
context.sharedContext.beginNewAuth(testingEnvironment: isTestingEnvironment)
|
||||
|
||||
dismissImpl?()
|
||||
let _ = (activeAccountsAndPeers(context: context)
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue
|
||||
).start(next: { accountAndPeer, accountsAndPeers in
|
||||
var maximumAvailableAccounts: Int = 3
|
||||
if accountAndPeer?.1.isPremium == true {
|
||||
maximumAvailableAccounts = 4
|
||||
}
|
||||
var count: Int = 1
|
||||
for (_, peer, _) in accountsAndPeers {
|
||||
if peer.isPremium {
|
||||
maximumAvailableAccounts = 4
|
||||
}
|
||||
}
|
||||
count += accountsAndPeers.count
|
||||
|
||||
if count >= maximumAvailableAccounts {
|
||||
var replaceImpl: ((ViewController) -> Void)?
|
||||
let controller = PremiumLimitScreen(context: context, subject: .accounts, count: Int32(count), action: {
|
||||
let controller = PremiumIntroScreen(context: context, source: .accounts)
|
||||
replaceImpl?(controller)
|
||||
})
|
||||
replaceImpl = { [weak controller] c in
|
||||
controller?.replace(with: c)
|
||||
}
|
||||
pushControllerImpl?(controller)
|
||||
} else {
|
||||
context.sharedContext.beginNewAuth(testingEnvironment: context.account.testingEnvironment)
|
||||
|
||||
dismissImpl?()
|
||||
}
|
||||
})
|
||||
}, setPasscode: {
|
||||
let _ = passcodeOptionsAccessController(context: context, pushController: { controller in
|
||||
replaceTopControllerImpl?(controller)
|
||||
|
||||
Reference in New Issue
Block a user