feat(post): persist new posts and wire like interactions

This commit is contained in:
zetaloop
2026-02-22 08:29:59 +08:00
parent 237cf90f5e
commit 43a0cf7a73
6 changed files with 136 additions and 28 deletions
+17
View File
@@ -83,6 +83,23 @@ export function PostComments({ initialComments, postId }: PostCommentsProps) {
<button
type="button"
className="flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground mt-1 transition-colors"
onClick={() =>
requireAuth(() => {
setComments((prev) =>
prev.map((item) => {
if (item.id !== comment.id) return item
const nextLiked = !item.liked
return {
...item,
liked: nextLiked,
likeCount: nextLiked
? item.likeCount + 1
: Math.max(0, item.likeCount - 1),
}
}),
)
})
}
>
<Heart
className={`h-3 w-3 ${comment.liked ? "fill-red-500 text-red-500" : ""}`}