Suggested changes
This commit is contained in:
parent
a616d9ed1c
commit
21b915f209
|
@ -1,7 +1,5 @@
|
|||
const NotificationsController = Ember.ArrayController.extend({
|
||||
export default Ember.ArrayController.extend({
|
||||
needs: ['header'],
|
||||
loadingNotifications: Em.computed.alias('controllers.header.loadingNotifications'),
|
||||
myNotificationsUrl: Discourse.computed.url('/my/notifications')
|
||||
});
|
||||
|
||||
export default NotificationsController;
|
||||
|
|
|
@ -56,7 +56,7 @@ export default {
|
|||
});
|
||||
});
|
||||
|
||||
initDesktopNotifications(container);
|
||||
initDesktopNotifications(bus);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
|
||||
let primaryTab;
|
||||
let liveEnabled;
|
||||
let notificationTagName;
|
||||
let mbClientId;
|
||||
let lastAction;
|
||||
let primaryTab = false;
|
||||
let liveEnabled = false;
|
||||
let mbClientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
|
||||
let lastAction = -1;
|
||||
|
||||
const focusTrackerKey = "focus-tracker";
|
||||
const seenDataKey = "seen-notifications";
|
||||
const recentUpdateThreshold = 1000 * 60 * 2; // 2 minutes
|
||||
const idleThresholdTime = 1000 * 10; // 10 seconds
|
||||
const INVITED_TYPE = 8;
|
||||
let notificationTagName; // "discourse-notification-popup-" + Discourse.SiteSettings.title;
|
||||
|
||||
function init(container) {
|
||||
// Called from an initializer
|
||||
function init(messageBus) {
|
||||
liveEnabled = false;
|
||||
mbClientId = messageBus.clientId;
|
||||
requestPermission().then(function() {
|
||||
try {
|
||||
localStorage.getItem(focusTrackerKey);
|
||||
} catch (e) {
|
||||
Em.Logger.info('Discourse desktop notifications are disabled - localStorage denied.');
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
liveEnabled = true;
|
||||
Em.Logger.info('Discourse desktop notifications are enabled.');
|
||||
return true;
|
||||
}).then(function(c) {
|
||||
if (c) {
|
||||
try {
|
||||
init2(container);
|
||||
// Permission is granted, continue with setup
|
||||
setupNotifications();
|
||||
} catch (e) {
|
||||
Em.Logger.error(e);
|
||||
}
|
||||
}
|
||||
}).catch(function() {
|
||||
liveEnabled = false;
|
||||
//Em.Logger.debug('Discourse desktop notifications are disabled - permission denied.');
|
||||
});
|
||||
}
|
||||
|
||||
function init2(container) {
|
||||
// This function is only called if permission was granted
|
||||
function setupNotifications() {
|
||||
// Load up the current state of the notifications
|
||||
const seenData = JSON.parse(localStorage.getItem(seenDataKey));
|
||||
let markAllSeen = true;
|
||||
|
@ -59,8 +59,6 @@ function init2(container) {
|
|||
|
||||
notificationTagName = "discourse-notification-popup-" + Discourse.SiteSettings.title;
|
||||
|
||||
const messageBus = container.lookup('message-bus:main');
|
||||
mbClientId = messageBus.clientId;
|
||||
|
||||
window.addEventListener("storage", function(e) {
|
||||
// note: This event only fires when other tabs setItem()
|
||||
|
@ -68,9 +66,7 @@ function init2(container) {
|
|||
if (key !== focusTrackerKey) {
|
||||
return true;
|
||||
}
|
||||
if (primaryTab) {
|
||||
primaryTab = false;
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener("focus", function() {
|
||||
|
@ -150,10 +146,6 @@ function onNotification(currentUser) {
|
|||
tag: notificationTagName
|
||||
});
|
||||
|
||||
// if (enableSound) {
|
||||
// soundElement.play();
|
||||
// }
|
||||
|
||||
const firstUnseen = unseen[0];
|
||||
|
||||
function clickEventHandler() {
|
||||
|
|
Loading…
Reference in New Issue