client/js: clearer state machine for html5 notification permissions

This commit is contained in:
mappu 2017-02-06 11:58:21 +13:00
parent d2b1d23ba6
commit 692537c6f0

View File

@ -151,16 +151,22 @@ var notify = function(title, body) {
return; // not supported by browser
}
if (window.Notification.permission === "granted") {
var nn = new Notification(title, {
switch (window.Notification.permission) {
case "granted": {
new Notification(title, {
body: body,
icon: DCWEBUI_CONF.extern + "/favicon.ico"
});
} break;
} else if (window.Notification.permission !== "denied") {
case "denied": return;
default: {
// Clarify permission and retry
Notification.requestPermission(function(permission) {
notify(title, body);
});
} break;
}
};