fix(feed): let users change poll votes#366
Conversation
Greptile SummaryThis PR makes poll result rows interactive for authenticated viewers by converting them to
Confidence Score: 5/5Safe to merge — the logic changes are small and well-tested, with no data-loss or security concerns introduced. The change correctly guards against redundant votes, properly conditionalizes the interactive vs. read-only rendering, and backs it with a passing test suite. The only gap is that the role="radiogroup" pattern conventionally requires roving tabindex and arrow-key handling, which is missing, but this does not affect data correctness or functional behavior. No files require special attention beyond the accessibility keyboard-navigation gap in PollDisplay.tsx. Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant PD as PollDisplay
participant API as /api/posts/:id/poll/vote
PD->>API: GET (on mount)
API-->>PD: "{ options, total_votes, user_vote }"
PD->>PD: Render result rows as radio buttons (isLoggedIn)
U->>PD: "Click different option (role="radio")"
PD->>PD: "Guard: optionId === userVote? skip"
PD->>PD: setVoting(true) disable all buttons
PD->>API: "POST { option_id }"
API-->>PD: "{ success: true }"
PD->>API: GET (refetch)
API-->>PD: "{ options, total_votes, user_vote }"
PD->>PD: setVoting(false) re-enable buttons
PD->>PD: Re-render with updated aria-checked state
Reviews (3): Last reviewed commit: "fix(feed): label poll choice groups" | Re-trigger Greptile |
Summary
Paid task
https://ugig.net/gigs/abd6b2a0-e728-48cf-a46f-f99e419ed94e
Verification
pnpm exec vitest run src/components/feed/PollDisplay.test.tsxpnpm exec eslint src/components/feed/PollDisplay.tsx src/components/feed/PollDisplay.test.tsxgit diff --check