fix(notifications): apply live READ/DELETED events to the store - #408
Open
pavlo-flamingo wants to merge 2 commits into
Open
pavlo-flamingo wants to merge 2 commits into
pavlo-flamingo wants to merge 2 commits into
Conversation
Marking a notification read (or deleting it) in one session left every other open session of the same user stale - the unread list and the badge only caught up on reload - even though CREATED arrived live in the same tab. The backend publishes READ/DELETED on the user's NATS subject with `notificationIds` only and no top-level id (openframe-oss-lib #1816). The live bridge guarded on that id before looking at `eventType`, so both events were dropped. - Branch on READ/DELETED before the id guard and run the existing mark-read / delete store updaters per id, then refetch the counts for ids outside the loaded window. - Make those updaters idempotent: the backend echoes the event back to the tab that fired the mutation, so a second pass must not insert a duplicate history row or decrement the badge twice. - Let /notifications register its search-keyed connection pair so the event reaches the table as well as the drawer.
Contributor
🦩 Flamingo Code ReviewNo findings on the current head. Mode: advisory Need another pass? Commits pushed after this review are not reviewed automatically.
Prefer typing? Comment React 👍/👎 on inline comments to teach the reviewer. Started 2026-09-15 15:43 UTC · updated 2026-09-15 15:44 UTC · workflow run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Mark as read / delete in one session does not reach the user's other open sessions: the New list and the unread badge stay stale until a reload, while
CREATEDarrives live in the same tab.Cause
The backend has published
READ/DELETEDonuser.<id>.notificationsince openframe-oss-lib #1816 —notificationIdsonly, no top-levelid. The live bridge checked for that id before looking ateventType, so both events were dropped. This predates #404; the context refactor did not touch this path.Fix
READ/DELETEDbefore the id guard; run the existing mark-read / delete store updaters per id, then refetch the counts for ids outside the loaded window.notifications-read-state.test.ts./notificationsregisters its search-keyed connection pair, so the event reaches the table as well as the drawer.Caveat
Verified on the wire shape (
NotificationNatsPublisher.publishReadStateToUser) and unit tests, not reproduced against a live backend from this branch. The listener only publishes whenspring.cloud.stream.enabledis on for the notifications service.