Stars reaction test [skip ci]

This commit is contained in:
Isaac
2024-06-27 14:39:09 +02:00
parent d65df43cb5
commit ad1ddf65c0
12 changed files with 326 additions and 72 deletions

View File

@@ -94,7 +94,26 @@ public func mergedMessageReactionsAndPeers(accountPeerId: EnginePeer.Id, account
}
}
return (attribute.reactions, recentPeers)
#if DEBUG
var reactions = attribute.reactions
if "".isEmpty {
if let index = reactions.firstIndex(where: {
if case .custom(MessageReaction.starsReactionId) = $0.value {
return true
} else {
return false
}
}) {
let value = reactions[index]
reactions.remove(at: index)
reactions.insert(value, at: 0)
} else {
reactions.insert(MessageReaction(value: .custom(MessageReaction.starsReactionId), count: 1000000, chosenOrder: nil), at: 0)
}
}
#endif
return (reactions, recentPeers)
}
private func mergeReactions(reactions: [MessageReaction], recentPeers: [ReactionsMessageAttribute.RecentPeer], pending: [PendingReactionsMessageAttribute.PendingReaction], accountPeerId: PeerId) -> ([MessageReaction], [ReactionsMessageAttribute.RecentPeer]) {