From 54f29398e2dec79dd953e215dbbc4ff81a177a73 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Fri, 13 Mar 2020 02:01:12 -0500 Subject: [PATCH] simplify some of the code for notifications --- js/chess.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/js/chess.js b/js/chess.js index 28716fe..323b052 100644 --- a/js/chess.js +++ b/js/chess.js @@ -602,13 +602,11 @@ function disableNotify(){ function requestNotify(){ try { - if (Notification && Notification.permission !== 'granted') { - Notification.requestPermission(function (permission){ - if (permission === 'denied') { - disableNotify(); - } - }); - } + Notification.requestPermission(function (permission){ + if (permission === 'denied') { + disableNotify(); + } + }); } catch (err) { disableNotify(); } @@ -637,7 +635,9 @@ function notify(body) { $(function (){ try { - if ('serviceWorker' in navigator) { + if (Notification.permission === 'denied') { + disableNotify(); + } else { navigator.serviceWorker.register('sw.js').catch(disableNotify); } } catch (err) { @@ -717,10 +717,6 @@ $(function (){ } }); - if (Notification.permission === 'denied') { - disableNotify(); - } - let updateMeta = function() { putMeta(); } $('#cb_light_name').on('input', updateMeta); $('#cb_dark_name').on('input', updateMeta);