diff --git a/web/src/components/Parts/Parts.js b/web/src/components/Parts/Parts.js index 1b8af53..71719b6 100644 --- a/web/src/components/Parts/Parts.js +++ b/web/src/components/Parts/Parts.js @@ -1,36 +1,59 @@ -import { useMutation, useFlash } from '@redwoodjs/web' +import { useMemo } from 'react' import { Link, routes } from '@redwoodjs/router' import ImageUploader from 'src/components/ImageUploader' const PartsList = ({ parts }) => { + 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 + }) + return Object.entries(emoteCounts).map(([emoji, count]) => ({emoji, count})).sort((a,b) => a.count-b.count).slice(-5) + } return (
-
diff --git a/web/src/components/PartsCell/PartsCell.js b/web/src/components/PartsCell/PartsCell.js index dc2cd9e..1490590 100644 --- a/web/src/components/PartsCell/PartsCell.js +++ b/web/src/components/PartsCell/PartsCell.js @@ -14,6 +14,9 @@ export const QUERY = gql` image userName } + Reaction { + emote + } } } `