diff options
| author | Egor Kislitsyn <egor@kislitsyn.com> | 2018-12-13 00:03:50 +0700 |
|---|---|---|
| committer | Egor Kislitsyn <egor@kislitsyn.com> | 2018-12-13 00:03:50 +0700 |
| commit | 02c0e15781fa0a499c736e710755e799bfaec77d (patch) | |
| tree | 0defdd796fb4e42e0e228d912622a6bbcc67db89 /static/sw.js | |
| parent | ee70ec4c7efb49c08f0a76b6b2694c0e9910978c (diff) | |
add checkbox to disable web push
Diffstat (limited to 'static/sw.js')
| -rw-r--r-- | static/sw.js | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/static/sw.js b/static/sw.js deleted file mode 100644 index d51870d5..00000000 --- a/static/sw.js +++ /dev/null @@ -1,29 +0,0 @@ -/* eslint-env serviceworker */ - -function getWindowClients () { - return clients.matchAll({ includeUncontrolled: true }) - .then((clientList) => clientList.filter(({ type }) => type === 'window')) -} - -self.addEventListener('push', (event) => { - if (event.data) { - event.waitUntil(getWindowClients().then((list) => { - const data = event.data.json() - - if (list.length === 0) return self.registration.showNotification(data.title, data) - })) - } -}) - -self.addEventListener('notificationclick', (event) => { - event.notification.close() - - event.waitUntil(getWindowClients().then((list) => { - for (var i = 0; i < list.length; i++) { - var client = list[i] - if (client.url === '/' && 'focus' in client) { return client.focus() } - } - - if (clients.openWindow) return clients.openWindow('/') - })) -}) |
