# Multiple desktop notifications for single reply

**URL:** https://meta.discourse.org/t/multiple-desktop-notifications-for-single-reply/36510
**Category:** Bug
**Created:** [2015年十二月10日 00:18 UTC](https://meta.discourse.org/t/multiple-desktop-notifications-for-single-reply/36510 "2015-12-10T00:18:21Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![jsha](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jsha/32/48894_2.png) [@jsha](https://meta.discourse.org/u/jsha)
#### Post date: [2015年十二月10日 00:18 UTC](https://meta.discourse.org/t/multiple-desktop-notifications-for-single-reply/36510/1 "2015-12-10T00:18:21Z")

</div>

This is on hosted site [https://community.letsencrypt.org](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.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [2015年十二月10日 02:37 UTC](https://meta.discourse.org/t/multiple-desktop-notifications-for-single-reply/36510/2 "2015-12-10T02:37:20Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![watchmanmonitor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/watchmanmonitor/32/430970_2.png) [@watchmanmonitor](https://meta.discourse.org/u/watchmanmonitor)
#### Post date: [2015年十二月10日 04:44 UTC](https://meta.discourse.org/t/multiple-desktop-notifications-for-single-reply/36510/3 "2015-12-10T04:44:54Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2015年十二月10日 05:03 UTC](https://meta.discourse.org/t/multiple-desktop-notifications-for-single-reply/36510/4 "2015-12-10T05:03:42Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2015年十二月10日 05:31 UTC](https://meta.discourse.org/t/multiple-desktop-notifications-for-single-reply/36510/5 "2015-12-10T05:31:47Z")

</div>

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](https://developer.mozilla.org/en-US/docs/Web/API/Notification/tag)  
> 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.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2015年十二月11日 02:36 UTC](https://meta.discourse.org/t/multiple-desktop-notifications-for-single-reply/36510/6 "2015-12-11T02:36:37Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2015年十二月12日 03:51 UTC](https://meta.discourse.org/t/multiple-desktop-notifications-for-single-reply/36510/7 "2015-12-12T03:51:28Z")

</div>

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 😅

Fix is here  
[https://github.com/discourse/discourse/pull/3919](https://github.com/discourse/discourse/pull/3919)

Thanks for the bug report @jsha!!

---

<div class="post-metadata">

### Author: ![jsha](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jsha/32/48894_2.png) [@jsha](https://meta.discourse.org/u/jsha)
#### Post date: [2015年十二月12日 05:15 UTC](https://meta.discourse.org/t/multiple-desktop-notifications-for-single-reply/36510/8 "2015-12-12T05:15:12Z")

</div>

Excellent, thanks for fixing!

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2015年十二月15日 10:50 UTC](https://meta.discourse.org/t/multiple-desktop-notifications-for-single-reply/36510/9 "2015-12-15T10:50:02Z")

</div>

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