From 6e98a183acd8247124f333c64f43bf2e7e7f45f7 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Sun, 22 Feb 2026 17:45:08 -0800 Subject: [PATCH] ip specific votes + ui fixes --- frontend.css | 9 +++++++-- frontend.tsx | 2 +- server.ts | 7 ++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/frontend.css b/frontend.css index 9ec4827..22fdafe 100644 --- a/frontend.css +++ b/frontend.css @@ -193,6 +193,7 @@ body { /* ── Contestant ───────────────────────────────────────────────── */ .contestant { + position: relative; border-left: 3px solid var(--accent); padding: 16px 20px; display: flex; @@ -343,14 +344,18 @@ body { } .my-vote-tag { + position: absolute; + top: 8px; + right: 8px; font-family: var(--mono); - font-size: 10px; + font-size: 9px; font-weight: 700; letter-spacing: 1px; - padding: 3px 8px; + padding: 2px 6px; border: 1px solid var(--text-muted); color: var(--text-dim); border-radius: 3px; + pointer-events: none; } /* ── Viewer Votes ────────────────────────────────────────────── */ diff --git a/frontend.tsx b/frontend.tsx index b7686a1..8283dbb 100644 --- a/frontend.tsx +++ b/frontend.tsx @@ -195,9 +195,9 @@ function ContestantCard({ >
- {isMyVote && YOUR PICK} {isWinner && WIN}
+ {isMyVote && YOUR PICK}
{!task.finishedAt ? ( diff --git a/server.ts b/server.ts index 06f62f1..4dc5fc6 100644 --- a/server.ts +++ b/server.ts @@ -229,7 +229,7 @@ function setHistoryCache(key: string, body: string, expiresAt: number) { // ── WebSocket clients ─────────────────────────────────────────────────────── const clients = new Set>(); -const viewerVoters = new Map, "A" | "B">(); +const viewerVoters = new Map(); let viewerVoteBroadcastTimer: ReturnType | null = null; function scheduleViewerVoteBroadcast() { @@ -624,14 +624,15 @@ const server = Bun.serve({ if (!round.viewerVotingEndsAt || Date.now() > round.viewerVotingEndsAt) return; if (msg.votedFor !== "A" && msg.votedFor !== "B") return; - const previousVote = viewerVoters.get(ws); + const ip = ws.data.ip; + const previousVote = viewerVoters.get(ip); if (previousVote === msg.votedFor) return; // same vote, ignore // Undo previous vote if changing if (previousVote === "A") round.viewerVotesA = Math.max(0, (round.viewerVotesA ?? 0) - 1); else if (previousVote === "B") round.viewerVotesB = Math.max(0, (round.viewerVotesB ?? 0) - 1); - viewerVoters.set(ws, msg.votedFor); + viewerVoters.set(ip, msg.votedFor); if (msg.votedFor === "A") round.viewerVotesA = (round.viewerVotesA ?? 0) + 1; else round.viewerVotesB = (round.viewerVotesB ?? 0) + 1;