Attempt to at move app into app sub dir

This commit is contained in:
Kurt Hutten
2021-05-01 07:32:21 +10:00
parent 9db76458d1
commit 78677a99f8
220 changed files with 1 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
export const countEmotes = (reactions = []) => {
// would be good to do this sever side
// counting unique emojis, and limiting to the 5 largest
const emoteCounts = {}
reactions.forEach(({ emote }) => {
emoteCounts[emote] = emoteCounts[emote] ? emoteCounts[emote] + 1 : 1
})
// TODO the sort is causing the emotes to jump around after the user clicks one, not ideal
return Object.entries(emoteCounts)
.map(([emoji, count]) => ({ emoji, count }))
.sort((a, b) => a.count - b.count)
.slice(-5)
}