feat: enhance CommunityTicketCard with upvote and comment functionality#91
feat: enhance CommunityTicketCard with upvote and comment functionality#91
Conversation
Reviewer's GuideRefactors the CommunityTicketCard UI to a richer, accessible card with avatar, attachment preview, and new upvote/comment interaction handlers, and wires those handlers into the community board page with local per-ticket upvote state tracking. Sequence diagram for ticket upvote toggle on CommunityBoardsequenceDiagram
actor User
participant CommunityBoardPage
participant CommunityTicketCard
participant UpvoteState as upvoteByTicketId
User->>CommunityTicketCard: Click upvote button
CommunityTicketCard->>CommunityTicketCard: stopPropagation()
CommunityTicketCard->>CommunityBoardPage: onUpvoteToggle(ticket)
CommunityBoardPage->>UpvoteState: Read current = upvoteByTicketId[ticket.id] || {count:0, upvoted:false}
CommunityBoardPage->>UpvoteState: Write updated entry
Note over UpvoteState: Toggle upvoted, increment or decrement count
UpvoteState-->>CommunityBoardPage: Updated state object
CommunityBoardPage-->>CommunityTicketCard: Re-render with
Note over CommunityBoardPage,CommunityTicketCard: upvoteCount and isUpvoted props updated
CommunityTicketCard->>User: Updated icon and count displayed
Sequence diagram for opening ticket comments from CommunityTicketCardsequenceDiagram
actor User
participant CommunityBoardPage
participant CommunityTicketCard
User->>CommunityTicketCard: Click comment button
CommunityTicketCard->>CommunityTicketCard: stopPropagation()
CommunityTicketCard->>CommunityBoardPage: onCommentClick(ticket)
CommunityBoardPage->>CommunityBoardPage: selectedTicket = ticket
CommunityBoardPage-->>User: Comments panel or details for selectedTicket shown
Flow diagram for CommunityBoard and CommunityTicketCard wiringgraph TD
A[CommunityBoardPage +page.svelte] -->|passes ticket,isActive,onClick,onCommentClick,onUpvoteToggle,upvoteCount,isUpvoted| B[CommunityTicketCard.svelte]
subgraph PageState
S1[selectedTicket]
S2[upvoteByTicketId Record]
end
A --> S1
A --> S2
B -->|onClick callback| A
B -->|onCommentClick callback| A
B -->|onUpvoteToggle callback| A
A -->|updates| S1
A -->|updates| S2
S2 -->|derived props per ticket id| A
A -->|re-renders with updated props| B
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... 📒 Files selected for processing (2)
✏️ Tip: You can disable in-progress messages and the fortune message in your review settings. Tip You can get early access to new features in CodeRabbit.Enable the ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
clickTimeris typed asNodeJS.Timeout, which can cause type mismatches in the browser; consider usinglet clickTimer: ReturnType<typeof setTimeout> | null = nullinstead for better compatibility in the Svelte client runtime. - The image modal currently only closes on mouse clicks; you may want to add keyboard handling (e.g. Escape key listener) to close it for better accessibility and keyboard navigation support.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `clickTimer` is typed as `NodeJS.Timeout`, which can cause type mismatches in the browser; consider using `let clickTimer: ReturnType<typeof setTimeout> | null = null` instead for better compatibility in the Svelte client runtime.
- The image modal currently only closes on mouse clicks; you may want to add keyboard handling (e.g. Escape key listener) to close it for better accessibility and keyboard navigation support.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
hueuhe
Summary by Sourcery
Enhance the community ticket card to support richer ticket display and interactive engagement controls.
New Features:
Enhancements:
Summary by CodeRabbit