Skip to content

Commit

Permalink
Remove like count from recipe show page
Browse files Browse the repository at this point in the history
  • Loading branch information
T1LT committed Jan 18, 2024
1 parent 0ad74ff commit 670047a
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions app/(recipes)/recipes/like-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ export default function LikeButton({
recipeId,
userLiked,
}: LikeButtonProps) {
const [optimisticLikes, setOptimisticLike] = useOptimistic(
likes,
(state, _) => (userLiked ? state - 1 : state + 1),
);
const [optimisticUserLiked, setOptimisticUserLiked] = useOptimistic(
userLiked,
(state, _) => !state,
);

const handleLike = async () => {
setOptimisticLike(1);
setOptimisticUserLiked(!userLiked);
await changeLike(recipeId, optimisticLikes, optimisticUserLiked);
await changeLike(recipeId, likes, optimisticUserLiked);
};

return (
Expand All @@ -37,7 +32,6 @@ export default function LikeButton({
onClick={handleLike}
fill={optimisticUserLiked ? "red" : "none"}
/>
<span className="text-lg tabular-nums">{Number(optimisticLikes)}</span>
</div>
);
}

0 comments on commit 670047a

Please sign in to comment.