fix(events): decrement the live like count on un-like #112

Merged
padreug merged 1 commit from fix/events-like-count-unlike into dev 2026-06-17 10:05:08 +00:00
Owner

Follow-up to #111. The live like count incremented in real time but un-likes didn't decrement until reload (observed: Bob removes his heart, Alice's count stays).

Cause: the subscription only watched bookmark lists by #a:[coord]. When someone removes the event, their new (replaceable kind-10003) list no longer contains the coord, so it stops matching the filter and never arrives.

Fix: also watch known likers by authors, and track each author's current set of liked coords — diffing previous vs current on every update so a dropped coord removes that author from the count live.

  • #a filter → discovers new likers.
  • authors filter → catches add and remove from anyone already counted (incl. their last un-like).

Verified end-to-end against a relay: count 5 → 6 on a like, then 6 → 5 on the same key's updated list with the coord dropped — no reload.

🤖 Generated with Claude Code

Follow-up to #111. The live like count incremented in real time but **un-likes didn't decrement until reload** (observed: Bob removes his heart, Alice's count stays). **Cause:** the subscription only watched bookmark lists by `#a:[coord]`. When someone removes the event, their new (replaceable kind-10003) list no longer contains the coord, so it stops matching the filter and never arrives. **Fix:** also watch known likers by `authors`, and track each author's current set of liked coords — diffing previous vs current on every update so a dropped coord removes that author from the count live. - `#a` filter → discovers new likers. - `authors` filter → catches add **and** remove from anyone already counted (incl. their last un-like). Verified end-to-end against a relay: count `5 → 6` on a like, then `6 → 5` on the same key's updated list with the coord dropped — **no reload**. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The like count only watched bookmark lists by #a, so when someone removed
an event their new (replaceable) list no longer matched the filter and
never arrived — the count stayed stale until reload. Also watch known
likers by `authors` and track each author's current liked-coords, diffing
prev vs next on every update so a dropped coord decrements live. Verified
end-to-end against a relay: a like incremented the count and the same
key's updated list (coord dropped) decremented it with no reload.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
padreug deleted branch fix/events-like-count-unlike 2026-06-17 10:05:08 +00:00
Sign in to join this conversation.
No description provided.