mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
web/timeline: don't render reactions if there are none
This commit is contained in:
parent
96019b6ef7
commit
6b4b12435a
1 changed files with 6 additions and 2 deletions
|
@ -41,14 +41,18 @@ const formatShortTime = (time: Date) =>
|
|||
`${time.getHours().toString().padStart(2, "0")}:${time.getMinutes().toString().padStart(2, "0")}`
|
||||
|
||||
const EventReactions = ({ reactions }: { reactions: Record<string, number> }) => {
|
||||
const reactionEntries = Object.entries(reactions).filter(([, count]) => count > 0).sort((a, b) => b[1] - a[1])
|
||||
if (reactionEntries.length === 0) {
|
||||
return null
|
||||
}
|
||||
return <div className="event-reactions">
|
||||
{Object.entries(reactions).map(([reaction, count]) => count > 0 ?
|
||||
{reactionEntries.map(([reaction, count]) =>
|
||||
<div key={reaction} className="reaction" title={reaction}>
|
||||
{reaction.startsWith("mxc://")
|
||||
? <img className="reaction-emoji" src={getMediaURL(reaction)} alt=""/>
|
||||
: <span className="reaction-emoji">{reaction}</span>}
|
||||
<span className="reaction-count">{count}</span>
|
||||
</div> : null)}
|
||||
</div>)}
|
||||
</div>
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue