forked from upstream-mirrors/quik
Merge pull request #676 from benwaffle/emoji-count
Display all reacted emojis
This commit is contained in:
@@ -402,18 +402,14 @@ class MessagesAdapter @Inject constructor(
|
|||||||
val hasReactions = reactions.isNotEmpty()
|
val hasReactions = reactions.isNotEmpty()
|
||||||
|
|
||||||
if (hasReactions) {
|
if (hasReactions) {
|
||||||
val reactionCounts = reactions.groupBy { it.emoji }
|
val uniqueEmojis = reactions.map { it.emoji }.distinct()
|
||||||
.mapValues { it.value.size }
|
val totalCount = reactions.size
|
||||||
.toList()
|
|
||||||
.sortedByDescending { it.second } // Sort by count, most reactions first
|
|
||||||
|
|
||||||
// For now, show just the first (most popular) reaction
|
// Show unique emojis followed by total count
|
||||||
val topReaction = reactionCounts.first()
|
val reactionText = if (totalCount == 1) {
|
||||||
val reactionText = if (topReaction.second == 1) {
|
uniqueEmojis.first()
|
||||||
topReaction.first
|
|
||||||
} else {
|
} else {
|
||||||
// Use a non-breaking space to keep the emoji and count together
|
"${uniqueEmojis.joinToString("")}\u00A0$totalCount"
|
||||||
"${topReaction.first}\u00A0${topReaction.second}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.reactionText?.text = reactionText
|
holder.reactionText?.text = reactionText
|
||||||
|
|||||||
Reference in New Issue
Block a user