diff --git a/src/components/chat/MessageReactions.tsx b/src/components/chat/MessageReactions.tsx index 484b05f..61957cd 100644 --- a/src/components/chat/MessageReactions.tsx +++ b/src/components/chat/MessageReactions.tsx @@ -1,10 +1,16 @@ -import { useMemo, useEffect } from "react"; +import { Fragment, useMemo, useEffect } from "react"; import { use$ } from "applesauce-react/hooks"; import { cn } from "@/lib/utils"; import eventStore from "@/services/event-store"; import pool from "@/services/relay-pool"; import accountManager from "@/services/accounts"; import { EMOJI_SHORTCODE_REGEX } from "@/lib/emoji-helpers"; +import { + Tooltip, + TooltipTrigger, + TooltipContent, +} from "@/components/ui/tooltip"; +import { UserName } from "@/components/nostr/UserName"; interface MessageReactionsProps { messageId: string; @@ -131,46 +137,67 @@ export function MessageReactions({ messageId, relays }: MessageReactionsProps) { if (aggregated.length === 0) return null; return ( -
- {aggregated.map((reaction) => ( - - ))} -
+ + +
+ {aggregated.map((reaction) => ( + + ))} +
+
+ +
+ {aggregated.map((reaction) => ( +
+ {reaction.customEmoji ? ( + {`:${reaction.customEmoji.shortcode}:`} + ) : ( + {reaction.emoji} + )} + + {reaction.pubkeys.map((pk, i) => ( + + {i > 0 && + (i === reaction.pubkeys.length - 1 ? ( + + and + + ) : ( + , + ))} + + + ))} + +
+ ))} +
+
+
); } -/** - * Single reaction badge with tooltip showing who reacted - */ function ReactionBadge({ reaction }: { reaction: ReactionSummary }) { - // Get active user to check if they reacted const activeAccount = use$(accountManager.active$); const hasUserReacted = activeAccount?.pubkey ? reaction.pubkeys.includes(activeAccount.pubkey) : false; - // Build tooltip with emoji and truncated pubkeys - const tooltip = useMemo(() => { - // Truncate pubkeys to first 8 chars for readability - const pubkeyList = reaction.pubkeys - .map((pk) => pk.slice(0, 8) + "...") - .join(", "); - - // Format: "❤️ 3\nabcd1234..., efgh5678..." - const emojiDisplay = reaction.customEmoji - ? `:${reaction.customEmoji.shortcode}:` - : reaction.emoji; - return `${emojiDisplay} ${reaction.count}\n${pubkeyList}`; - }, [reaction]); - return ( - + {reaction.customEmoji ? (