Reaction improvements

This commit is contained in:
Ali
2021-12-27 22:36:34 +04:00
parent d3164fa4cd
commit 8ef10ee6c2
4 changed files with 298 additions and 161 deletions

View File

@@ -233,6 +233,7 @@ public extension EngineMessageReactionListContext.State {
init(message: EngineMessage, reaction: String?) {
var totalCount = 0
var hasOutgoingReaction = false
var items: [EngineMessageReactionListContext.Item] = []
if let reactionsAttribute = message._asMessage().reactionsAttribute {
for messageReaction in reactionsAttribute.reactions {
if reaction == nil || messageReaction.value == reaction {
@@ -242,12 +243,20 @@ public extension EngineMessageReactionListContext.State {
totalCount += Int(messageReaction.count)
}
}
for recentPeer in reactionsAttribute.recentPeers {
if let peer = message.peers[recentPeer.peerId] {
items.append(EngineMessageReactionListContext.Item(peer: EnginePeer(peer), reaction: recentPeer.value))
}
}
}
if items.count != totalCount {
items.removeAll()
}
self.init(
hasOutgoingReaction: hasOutgoingReaction,
totalCount: totalCount,
items: [],
canLoadMore: totalCount != 0
items: items,
canLoadMore: items.count != totalCount && totalCount != 0
)
}
}