mirror of
https://github.com/layer-systems/website.git
synced 2026-09-13 06:07:29 +02:00
* Add NIP-25 reactions to notes and replies Signed-in users can like a note or reply from the feed, a thread view, or its replies. The like count and the viewer's own reaction state come from kind-7 events tagged to the target; liking publishes a kind 7 with content "+", and un-liking publishes a NIP-09 deletion of the viewer's own reaction rather than a competing "-" event, since deletions are what most relays and clients actually honor. Updates are optimistic (instant toggle, rollback on publish failure) and reconcile against relays afterward. Signed-out users get the sign-in dialog instead of a silent no-op. Closes #53 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BYiUtZMQeA5RHggQw73wto * Fix reaction un-like to delete all of the user's reaction events Addresses Copilot review feedback on PR #61: deleting only the latest of a user's kind-7 reactions let an older `+` resurface as "the" reaction after refetch, silently re-inflating the like count. Now a single NIP-09 deletion covers every one of the viewer's own reaction events on the target, tagged with `k` (7) to match this repo's other deletion events (useWebBookmarks). While validating this live against real relays, found and fixed two more bugs in the same toggle mutation, both stemming from the eventual-consistency trap already fixed for mute lists on another branch: - `onSettled` force-invalidated the reactions query right after a successful publish; the refetch could hit a relay that hadn't indexed the new event yet and silently revert a like back to "unliked" about a second later. - Fixing that naively (dropping the invalidate) left the optimistic placeholder's fake `optimistic:...` id in the cache forever, so a like immediately followed by an unlike built a deletion event that targeted an id no relay had ever seen. Both are fixed by writing the mutation's own known-correct result (the real signed event, or its removal) straight into the query cache on success, instead of trusting an immediate relay re-read. Confirmed live with a throwaway account against production relays: liking persists after the optimistic phase, unliking's deletion event targets the real reaction id, and two full like/unlike cycles remain stable. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BYiUtZMQeA5RHggQw73wto --------- Co-authored-by: highperfocused <highperfocused@pm.me> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>