client/js: clearer state machine for html5 notification permissions
This commit is contained in:
parent
d2b1d23ba6
commit
692537c6f0
@ -151,16 +151,22 @@ var notify = function(title, body) {
|
||||
return; // not supported by browser
|
||||
}
|
||||
|
||||
if (window.Notification.permission === "granted") {
|
||||
var nn = new Notification(title, {
|
||||
body: body,
|
||||
icon: DCWEBUI_CONF.extern + "/favicon.ico"
|
||||
});
|
||||
switch (window.Notification.permission) {
|
||||
case "granted": {
|
||||
new Notification(title, {
|
||||
body: body,
|
||||
icon: DCWEBUI_CONF.extern + "/favicon.ico"
|
||||
});
|
||||
} break;
|
||||
|
||||
} else if (window.Notification.permission !== "denied") {
|
||||
Notification.requestPermission(function(permission) {
|
||||
notify(title, body);
|
||||
});
|
||||
case "denied": return;
|
||||
|
||||
default: {
|
||||
// Clarify permission and retry
|
||||
Notification.requestPermission(function(permission) {
|
||||
notify(title, body);
|
||||
});
|
||||
} break;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user