Channel reaction improvements

This commit is contained in:
Isaac
2023-11-25 23:07:15 +04:00
parent afdc11b171
commit 48a2a72a6a
11 changed files with 311 additions and 187 deletions

View File

@@ -112,6 +112,10 @@ extension ChatControllerImpl {
actions.reactionItems = topReactions.map(ReactionContextItem.reaction)
actions.selectedReactionItems = selectedReactions.reactions
if let channel = self.presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, case .broadcast = channel.info {
actions.alwaysAllowPremiumReactions = true
}
if !actions.reactionItems.isEmpty {
let reactionItems: [EmojiComponentReactionItem] = actions.reactionItems.compactMap { item -> EmojiComponentReactionItem? in
switch item {
@@ -150,7 +154,7 @@ extension ChatControllerImpl {
animationCache: animationCache,
animationRenderer: animationRenderer,
isStandalone: false,
subject: .reaction,
subject: .reaction(onlyTop: false),
hasTrending: false,
topReactionItems: reactionItems,
areUnicodeEmojiEnabled: false,
@@ -159,6 +163,26 @@ extension ChatControllerImpl {
selectedItems: selectedReactions.files
)
}
} else if reactionItems.count > 10 {
actions.getEmojiContent = { [weak self] animationCache, animationRenderer in
guard let self else {
preconditionFailure()
}
return EmojiPagerContentComponent.emojiInputData(
context: self.context,
animationCache: animationCache,
animationRenderer: animationRenderer,
isStandalone: false,
subject: .reaction(onlyTop: true),
hasTrending: false,
topReactionItems: reactionItems,
areUnicodeEmojiEnabled: false,
areCustomEmojiEnabled: false,
chatPeerId: self.chatLocation.peerId,
selectedItems: selectedReactions.files
)
}
}
}
}
@@ -332,9 +356,12 @@ extension ChatControllerImpl {
}*/
if removedReaction == nil, case .custom = chosenReaction {
if !self.presentationInterfaceState.isPremium {
controller?.premiumReactionsSelected?()
return
if let peer = self.presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, case .broadcast = peer.info {
} else {
if !self.presentationInterfaceState.isPremium {
controller?.premiumReactionsSelected?()
return
}
}
}