From 02c0e15781fa0a499c736e710755e799bfaec77d Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Thu, 13 Dec 2018 00:03:50 +0700 Subject: add checkbox to disable web push --- static/sw.js | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 static/sw.js (limited to 'static/sw.js') 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('/') - })) -}) -- cgit v1.2.3-70-g09d2