Multiple desktop notifications for single reply

This is on hosted site https://community.letsencrypt.org, using Chrome 47 / Ubuntu.

Steps to reproduce:

  • Enable desktop notifications in Discourse and allow them in Chrome.
  • Open two browser tabs pointing to the same Discourse instances.
  • Wait for someone to reply to one of your topics.

Expected result:

  • Single desktop notification

Actual result:

  • Desktop notification appears, goes away after a few seconds, and then appears again.
4 Likes

I believe this is a Chrome bug, not Discourse, as I have the same issue with other sites that have Chrome notifications…but I could be wrong!

2 Likes

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.

@riking is there anything we can do here to stop this from happening?

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.

7 Likes

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.

5 Likes

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 :sweat_smile:

Fix is here
https://github.com/discourse/discourse/pull/3919

Thanks for the bug report @jsha!!

9 Likes

Excellent, thanks for fixing!

1 Like

This topic was automatically closed after 3 days. New replies are no longer allowed.