Imagine you have the same app open in three tabs.
Tab A: the dashboard. Tab B: a report. Tab C: settings, opened twenty minutes ago and forgotten.
A notification comes in. You open it in tab A and read it. The red badge goes away.
You switch to tab B. Red badge. Tab C? Red badge.
The badge is very confident. It is also wrong.
The read was saved. The server knows. Every tab has its own idea of what you've read, and only one of them was there when it happened. The other two will find out on the next reload, which might be tomorrow.
It's a small thing that makes an app feel out of sync with itself. I fixed exactly this for notifications in an app I work on, with BroadcastChannel . Here's how it went, from ten lines to the version that shipped.
The full code, with tests, is in my pocket-patterns repo on GitHub if you'd rather read along.
1. What we were working with
Here's the setup:
Notifications arrive over SSE.…