fix(feed): show poll results to anonymous viewers#365
Conversation
Greptile SummaryThis PR fixes a one-line bug in
Confidence Score: 5/5Safe to merge — the change is a single targeted prop correction backed by focused tests. The fix is minimal and self-contained: one prop expression corrected from a hardcoded true to !!currentUserId, matching the identical pattern already used in canEdit on line 46 of the same file. PollDisplay already handled isLoggedIn: false correctly (read-only result bars), so no downstream logic needed adjustment. The new tests cover both anonymous and authenticated render paths at the right level of abstraction. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Parent as Page/Feed
participant PC as PostCard
participant PD as PollDisplay
participant API as /api/posts/:id/poll/vote
Note over Parent,PC: Anonymous viewer (currentUserId = undefined)
Parent->>PC: render PostCard without currentUserId
PC->>PD: "PollDisplay isLoggedIn=false"
PD->>API: GET fetch results
API-->>PD: options, total_votes
Note over PD: showResults=true, renders read-only bars
Note over Parent,PC: Authenticated viewer (currentUserId = user-1)
Parent->>PC: render PostCard with currentUserId
PC->>PD: "PollDisplay isLoggedIn=true"
PD->>API: GET fetch results
API-->>PD: options, total_votes, user_vote
alt user has already voted
Note over PD: showResults=true, result bars
else user has not voted
Note over PD: showResults=false, vote buttons
PD->>API: POST option_id on click
API-->>PD: updated results
end
Reviews (1): Last reviewed commit: "fix(feed): show poll results to anonymou..." | Re-trigger Greptile |
Summary
PostCardintoPollDisplay401Paid task
https://ugig.net/gigs/abd6b2a0-e728-48cf-a46f-f99e419ed94e
Verification
pnpm exec vitest run src/components/feed/PostCard.test.tsxpnpm exec eslint src/components/feed/PostCard.tsx src/components/feed/PostCard.test.tsxgit diff --check