mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Close the notification after 10 seconds
This commit is contained in:
parent
c1528e598f
commit
84896bdccf
@ -95,24 +95,31 @@ export default Discourse.Controller.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const firstUnseen = unseen[0];
|
const firstUnseen = unseen[0];
|
||||||
notification.addEventListener('click', function() {
|
|
||||||
window.location.href = notificationUrl(firstUnseen);
|
notification.addEventListener('click', self.clickEventHandler);
|
||||||
window.focus();
|
setTimeout(function() {
|
||||||
});
|
notification.close();
|
||||||
|
notification.removeEventListener('click', self.clickEventHandler);
|
||||||
|
}, 10 * 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clickEventHandler() {
|
||||||
|
window.location.href = notificationUrl(firstUnseen);
|
||||||
|
window.focus();
|
||||||
|
},
|
||||||
|
|
||||||
// Utility function
|
// Utility function
|
||||||
// Wraps Notification.requestPermission in a Promise
|
// Wraps Notification.requestPermission in a Promise
|
||||||
requestPermission() {
|
requestPermission() {
|
||||||
return new Ember.RSVP.Promise(function(resolve, reject) {
|
return new Ember.RSVP.Promise(function(resolve, reject) {
|
||||||
console.log('requesting');
|
|
||||||
Notification.requestPermission(function(status) {
|
Notification.requestPermission(function(status) {
|
||||||
console.log('requested, status:', status);
|
|
||||||
if (status === "granted") {
|
if (status === "granted") {
|
||||||
|
Em.Logger.info('Discourse desktop notifications are enabled.');
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
|
Em.Logger.info('Discourse desktop notifications are disabled.');
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user