Merge pull request #3465 from riking/patch-2
FEATURE: Multiple notifications at once (1/topic)
This commit is contained in:
commit
0b62730382
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue