import { ALLOWED_REACTIONS } from "../constants.ts"; import type { SessionUser } from "../middleware/session.ts"; export interface ReactionCount { emoji: string; count: number; userReacted: boolean; } interface ReactionBarProps { reactions: ReactionCount[]; postUrl: string; commentId?: number; user: SessionUser | null; } export function ReactionBar({ reactions, postUrl, commentId, user, }: ReactionBarProps) { if (!user && reactions.length === 0) return null; const existing = new Set(reactions.map((r) => r.emoji)); const all = [...ALLOWED_REACTIONS]; return (
{reactions.map((r) => { const unsafeEmoji = r.emoji; return (
{commentId != null && ( )}
); })} {!!user && (
+
{all .filter((e) => !existing.has(e)) .map((e) => (
{commentId != null && ( )}
))}
)}
); }