I don’t remember this happening at first… but couldn’t say if it was a new version of Chrome or Discourse that made me see multiple notifications frequently.
I would actually classify it as a Discourse bug because we’re the ones triggering two notifications. Each open tab subscribes to a messagebus callback that creates a new notification. Therefore, two open tabs equals two notifications created.
Right now, we’re assigning tags to each notification but all it does is replace the notification that has the same tag which is why we’re seeing the behavior here.
Notification: tag property - Web APIs | MDN
The idea of notification tags is that more than one notification can share the same tag, linking them together. One notification can then be programmatically replaced with another to avoid the users’ screen being filled up with a huge number of similar notifications.
Using push notifications through service workers would fix/replace this but without support for a data payload in push yet, it is going to be tricky to implement correctly.
Oh right, another thing that should be done, in addition to what @tgxworld said, is to stop auto-clearing the notification after 10 seconds, as the browser now does that.
Clearing it after 10 seconds causes problems if, e.g. you are watching a full-screen video, where normally notifications are delayed until you exit fullscreen.
Ah ok. Actually the implementation by @riking had a check for the primary tab. So even though we have two tabs open, it’ll only trigger notifications on the “active” tab by setting the values in localStorage. We made some internal changes that broke it