ui: add a useless service worker

This commit is contained in:
undefined committed 2022-08-31 12:38:38 +08:00
1 parent 023a13b066
commit ccb380852f
6 files changed
+43 -7

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
/// <reference types="@types/serviceworker" />
/* global clients */
// eslint-disable-next-line no-restricted-globals
addEventListener('notificationclick', (event) => {
console.log('On notification click: ', event.notification.tag);
event.notification.close();
if (!event.notification.tag.startsWith('message-')) return;
event.waitUntil(clients.matchAll({ type: 'window' }).then((clientList) => {
for (const client of clientList) {
if (client.url === '/home/messages' && 'focus' in client) return client.focus();
}
if (clients.openWindow) clients.openWindow('/home/messages');
}));
});