FEATURE: Multiple notifications at once (1/topic)

This commit is contained in:
riking 2015-05-13 18:20:27 -07:00
parent 82cc467d93
commit 28f32aff66
2 changed files with 3 additions and 6 deletions

View File

@ -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() {

View File

@ -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