Prevent "0 new notifications"
This commit is contained in:
parent
59bdff348c
commit
41819838ef
|
@ -63,7 +63,7 @@ export default Discourse.Controller.extend({
|
||||||
const unreadCount = unread.length;
|
const unreadCount = unread.length;
|
||||||
const unseenCount = unseen.length;
|
const unseenCount = unseen.length;
|
||||||
|
|
||||||
if (unseenCount === 0) {
|
if (unreadCount === 0 || unseenCount === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (typeof document.hidden !== "undefined" && !document.hidden) {
|
if (typeof document.hidden !== "undefined" && !document.hidden) {
|
||||||
|
@ -96,20 +96,22 @@ export default Discourse.Controller.extend({
|
||||||
|
|
||||||
const firstUnseen = unseen[0];
|
const firstUnseen = unseen[0];
|
||||||
|
|
||||||
notification.addEventListener('click', self.clickEventHandler);
|
function clickEventHandler() {
|
||||||
|
Discourse.URL.routeTo(notificationUrl(firstUnseen));
|
||||||
|
// Cannot delay this until the page renders :(
|
||||||
|
// due to trigger-based permissions
|
||||||
|
window.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
notification.addEventListener('click', clickEventHandler);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
notification.close();
|
notification.close();
|
||||||
notification.removeEventListener('click', self.clickEventHandler);
|
notification.removeEventListener('click', clickEventHandler);
|
||||||
}, 10 * 1000);
|
}, 10 * 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
clickEventHandler() {
|
|
||||||
Discourse.URL.routeTo(notificationUrl(firstUnseen));
|
|
||||||
window.focus();
|
|
||||||
},
|
|
||||||
|
|
||||||
// Utility function
|
// Utility function
|
||||||
// Wraps Notification.requestPermission in a Promise
|
// Wraps Notification.requestPermission in a Promise
|
||||||
requestPermission() {
|
requestPermission() {
|
||||||
|
|
Loading…
Reference in New Issue