mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-02 10:50:11 +00:00
Add chat limit screen
This commit is contained in:
parent
806d3d4ea4
commit
ffbc8883e2
@ -362,7 +362,7 @@ public enum JoinChatFolderLinkError {
|
|||||||
case generic
|
case generic
|
||||||
case dialogFilterLimitExceeded(limit: Int32, premiumLimit: Int32)
|
case dialogFilterLimitExceeded(limit: Int32, premiumLimit: Int32)
|
||||||
case sharedFolderLimitExceeded(limit: Int32, premiumLimit: Int32)
|
case sharedFolderLimitExceeded(limit: Int32, premiumLimit: Int32)
|
||||||
case tooManyChannels
|
case tooManyChannels(limit: Int32, premiumLimit: Int32)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _internal_joinChatFolderLink(account: Account, slug: String, peerIds: [EnginePeer.Id]) -> Signal<Never, JoinChatFolderLinkError> {
|
func _internal_joinChatFolderLink(account: Account, slug: String, peerIds: [EnginePeer.Id]) -> Signal<Never, JoinChatFolderLinkError> {
|
||||||
@ -374,7 +374,20 @@ func _internal_joinChatFolderLink(account: Account, slug: String, peerIds: [Engi
|
|||||||
return account.network.request(Api.functions.communities.joinCommunityInvite(slug: slug, peers: inputPeers))
|
return account.network.request(Api.functions.communities.joinCommunityInvite(slug: slug, peers: inputPeers))
|
||||||
|> `catch` { error -> Signal<Api.Updates, JoinChatFolderLinkError> in
|
|> `catch` { error -> Signal<Api.Updates, JoinChatFolderLinkError> in
|
||||||
if error.errorDescription == "USER_CHANNELS_TOO_MUCH" {
|
if error.errorDescription == "USER_CHANNELS_TOO_MUCH" {
|
||||||
return .fail(.tooManyChannels)
|
return account.postbox.transaction { transaction -> (AppConfiguration, Bool) in
|
||||||
|
return (currentAppConfiguration(transaction: transaction), transaction.getPeer(account.peerId)?.isPremium ?? false)
|
||||||
|
}
|
||||||
|
|> castError(JoinChatFolderLinkError.self)
|
||||||
|
|> mapToSignal { appConfiguration, isPremium -> Signal<Api.Updates, JoinChatFolderLinkError> in
|
||||||
|
let userDefaultLimits = UserLimitsConfiguration(appConfiguration: appConfiguration, isPremium: false)
|
||||||
|
let userPremiumLimits = UserLimitsConfiguration(appConfiguration: appConfiguration, isPremium: true)
|
||||||
|
|
||||||
|
if isPremium {
|
||||||
|
return .fail(.tooManyChannels(limit: userPremiumLimits.maxFolderChatsCount, premiumLimit: userPremiumLimits.maxFolderChatsCount))
|
||||||
|
} else {
|
||||||
|
return .fail(.tooManyChannels(limit: userDefaultLimits.maxFolderChatsCount, premiumLimit: userPremiumLimits.maxFolderChatsCount))
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if error.errorDescription == "DIALOG_FILTERS_TOO_MUCH" {
|
} else if error.errorDescription == "DIALOG_FILTERS_TOO_MUCH" {
|
||||||
return account.postbox.transaction { transaction -> (AppConfiguration, Bool) in
|
return account.postbox.transaction { transaction -> (AppConfiguration, Bool) in
|
||||||
return (currentAppConfiguration(transaction: transaction), transaction.getPeer(account.peerId)?.isPremium ?? false)
|
return (currentAppConfiguration(transaction: transaction), transaction.getPeer(account.peerId)?.isPremium ?? false)
|
||||||
|
@ -757,6 +757,10 @@ private final class ChatFolderLinkPreviewScreenComponent: Component {
|
|||||||
let limitController = PremiumLimitScreen(context: component.context, subject: .membershipInSharedFolders, count: limit, action: {})
|
let limitController = PremiumLimitScreen(context: component.context, subject: .membershipInSharedFolders, count: limit, action: {})
|
||||||
controller.push(limitController)
|
controller.push(limitController)
|
||||||
controller.dismiss()
|
controller.dismiss()
|
||||||
|
case let .tooManyChannels(limit, _):
|
||||||
|
let limitController = PremiumLimitScreen(context: component.context, subject: .chatsPerFolder, count: limit, action: {})
|
||||||
|
controller.push(limitController)
|
||||||
|
controller.dismiss()
|
||||||
}
|
}
|
||||||
}, completed: { [weak self] in
|
}, completed: { [weak self] in
|
||||||
guard let self, let controller = self.environment?.controller() else {
|
guard let self, let controller = self.environment?.controller() else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user