Skip to content

feat(posts): make the like button a real toggle - #55

Merged
YonatanHen merged 1 commit into
stagingfrom
dev/like-toggle
Aug 1, 2026
Merged

feat(posts): make the like button a real toggle#55
YonatanHen merged 1 commit into
stagingfrom
dev/like-toggle

Conversation

@YonatanHen

Copy link
Copy Markdown
Owner

Summary

  • PostDto now carries a per-viewer liked flag (undefined for anonymous readers), computed with one batched query per list/detail fetch rather than N+1.
  • LikeButton toggles between like (PUT) and unlike (DELETE) based on that flag, and fills the heart icon when liked.
  • Both useLikePost and the new useUnlikePost optimistically flip liked and the count, with rollback on error.

Test plan

  • npm run test — 491 passing (15 new: server-side liked field for anonymous/owner/isolation, client-side toggle dispatch, optimistic flip/rollback, filled vs outline heart)
  • CI green on this PR

PostDto now carries a per-viewer liked flag (batched lookup, never one
query per post) so the feed and post page know whether the current
reader already liked a post. LikeButton picks like vs unlike based on
that flag and fills the heart when liked; useUnlikePost mirrors
useLikePost's optimistic update/rollback, just decrementing and
flipping liked false instead of true.
@YonatanHen
YonatanHen merged commit 8817126 into staging Aug 1, 2026
5 checks passed
@YonatanHen
YonatanHen deleted the dev/like-toggle branch August 1, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant