Category: Feature / Bug Fix
Difficulty: High
Description
likePost in ForumContext.tsx increments the like count infinitely on every click — there is no toggle, no per-user tracking, and a user can like the same post hundreds of times. There is also no visual distinction between "liked" and "not liked" state in ForumFeed.tsx.
Problem Statement
// ForumContext.tsx
const likePost = (postId: string) => {
setPosts(prev => prev.map(post => {
if (post.id === postId) {
return { ...post, likes: post.likes + 1 }; // no toggle, no user check
}
return post;
}));
};
Technical Requirements
- Add a
likedBy: string[] array (user IDs) to the Post interface in ForumContext
likePost must toggle: if user.id is in likedBy, remove it and decrement; otherwise add and increment
- The like button in
ForumFeed.tsx must show a filled/colored heart icon when the current user has liked the post
- Debounce persistence to localStorage by 300ms to avoid thrashing on rapid clicks
- Unauthenticated users clicking like must be redirected to
/signup with a toast prompt
- Animate the like count change using a CSS keyframe
+1 pop animation
Acceptance Criteria
Deliverables
- Updated
ForumContext.tsx (Post interface + likePost)
- Updated
ForumFeed.tsx (like button UI)
Category: Feature / Bug Fix
Difficulty: High
Description
likePostinForumContext.tsxincrements the like count infinitely on every click — there is no toggle, no per-user tracking, and a user can like the same post hundreds of times. There is also no visual distinction between "liked" and "not liked" state inForumFeed.tsx.Problem Statement
Technical Requirements
likedBy: string[]array (user IDs) to thePostinterface inForumContextlikePostmust toggle: ifuser.idis inlikedBy, remove it and decrement; otherwise add and incrementForumFeed.tsxmust show a filled/colored heart icon when the current user has liked the post/signupwith a toast prompt+1pop animationAcceptance Criteria
Deliverables
ForumContext.tsx(Post interface + likePost)ForumFeed.tsx(like button UI)