"use client"; import { useCallback, useState } from "react"; import type { ForumThread } from "@/lib/forumState"; import { displayScore, getVoteForThread, setVoteForThread, type VoteChoice, } from "@/lib/forumState"; export function ThreadVoteColumn({ thread, dense, onVoteChange, }: { thread: ForumThread; dense?: boolean; onVoteChange?: () => void; }) { const [tick, setTick] = useState(0); const choice = getVoteForThread(thread.id); const score = displayScore(thread); const apply = useCallback( (dir: 1 | -1) => { const cur = getVoteForThread(thread.id); let next: VoteChoice = dir; if (cur === dir) next = 0; setVoteForThread(thread.id, next); setTick((t) => t + 1); onVoteChange?.(); }, [thread.id, onVoteChange], ); void tick; const btn = dense ? "px-1 py-0.5 text-[10px]" : "px-1.5 py-1 text-xs"; return (
{score}
); }