mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: add a useless service worker
This commit is contained in:
1 parent
023a13b066
commit
ccb380852f
6 files changed
+43
-7
No files matched your search
@@ -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');
|
||||
}));
|
||||
});
|
||||
Reference in new issue
Block a user