From 28f32aff66b768ee1b9b0c3ff8a2f31833063215 Mon Sep 17 00:00:00 2001 From: riking Date: Wed, 13 May 2015 18:20:27 -0700 Subject: [PATCH] FEATURE: Multiple notifications at once (1/topic) --- .../discourse/lib/desktop-notifications.js.es6 | 8 ++------ app/services/post_alerter.rb | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 b/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 index 27cdb909132..5d7b18db0f9 100644 --- a/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 +++ b/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 @@ -7,7 +7,6 @@ let lastAction = -1; const focusTrackerKey = "focus-tracker"; const idleThresholdTime = 1000 * 10; // 10 seconds -let notificationTagName; // "discourse-notification-popup-" + Discourse.SiteSettings.title; // Called from an initializer function init(messageBus) { @@ -25,8 +24,6 @@ function init(messageBus) { return; } - - if (!("Notification" in window)) { Em.Logger.info('Discourse desktop notifications are disabled - not supported by browser'); return; @@ -55,8 +52,6 @@ function init(messageBus) { // This function is only called if permission was granted function setupNotifications() { - notificationTagName = "discourse-notification-popup-" + Discourse.SiteSettings.title; - window.addEventListener("storage", function(e) { // note: This event only fires when other tabs setItem() const key = e.key; @@ -108,13 +103,14 @@ function onNotification(data) { const notificationBody = data.excerpt; const notificationIcon = Discourse.SiteSettings.logo_small_url || Discourse.SiteSettings.logo_url; + const notificationTag = "discourse-notification-" + Discourse.SiteSettings.title + "-" + data.topic_id; requestPermission().then(function() { // This shows the notification! const notification = new Notification(notificationTitle, { body: notificationBody, icon: notificationIcon, - tag: notificationTagName + tag: notificationTag }); function clickEventHandler() { diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rb index 5115e1c2ff8..6d9ce26f91d 100644 --- a/app/services/post_alerter.rb +++ b/app/services/post_alerter.rb @@ -157,6 +157,7 @@ class PostAlerter notification_type: type, post_number: original_post.post_number, topic_title: original_post.topic.title, + topic_id: original_post.topic.id, excerpt: original_post.excerpt(400, text_entities: true, strip_links: true), username: original_username, post_url: post_url