simplify some of the code for notifications

This commit is contained in:
Jesse D. McDonald 2020-03-13 02:01:12 -05:00
parent 1f754f53a3
commit 54f29398e2
1 changed files with 8 additions and 12 deletions

View File

@ -602,13 +602,11 @@ function disableNotify(){
function requestNotify(){ function requestNotify(){
try { try {
if (Notification && Notification.permission !== 'granted') { Notification.requestPermission(function (permission){
Notification.requestPermission(function (permission){ if (permission === 'denied') {
if (permission === 'denied') { disableNotify();
disableNotify(); }
} });
});
}
} catch (err) { } catch (err) {
disableNotify(); disableNotify();
} }
@ -637,7 +635,9 @@ function notify(body) {
$(function (){ $(function (){
try { try {
if ('serviceWorker' in navigator) { if (Notification.permission === 'denied') {
disableNotify();
} else {
navigator.serviceWorker.register('sw.js').catch(disableNotify); navigator.serviceWorker.register('sw.js').catch(disableNotify);
} }
} catch (err) { } catch (err) {
@ -717,10 +717,6 @@ $(function (){
} }
}); });
if (Notification.permission === 'denied') {
disableNotify();
}
let updateMeta = function() { putMeta(); } let updateMeta = function() { putMeta(); }
$('#cb_light_name').on('input', updateMeta); $('#cb_light_name').on('input', updateMeta);
$('#cb_dark_name').on('input', updateMeta); $('#cb_dark_name').on('input', updateMeta);