Improve Notification probing

This commit is contained in:
Sam 2015-05-04 11:14:03 +10:00
parent 5623827433
commit 1c7fa956dc
1 changed files with 11 additions and 12 deletions

View File

@ -30,21 +30,20 @@ function init(messageBus) {
try { if (!("Notification" in window)) {
if (!Notification) { Em.Logger.info('Discourse desktop notifications are disabled - not supported by browser');
Em.Logger.info('Discourse desktop notifications are disabled - not supported by browser');
return;
}
} catch (e) {
Em.Logger.info('Discourse desktop notifications are disabled - not defined');
return; return;
} }
if (Notification.permission === "granted") { try {
havePermission = true; if (Notification.permission === "granted") {
} else if (Notification.permission === "denied") { havePermission = true;
havePermission = false; } else if (Notification.permission === "denied") {
return; havePermission = false;
return;
}
} catch (e) {
Em.Logger.warn('Unexpected error, Notification is defined on window but not a responding correctly ' + e);
} }
liveEnabled = true; liveEnabled = true;