aboutsummaryrefslogtreecommitdiffstats
path: root/build.js
diff options
context:
space:
mode:
Diffstat (limited to 'build.js')
-rw-r--r--build.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/build.js b/build.js
index ae9aee9..0f2373e 100644
--- a/build.js
+++ b/build.js
@@ -219,11 +219,15 @@ const SW_WAKE_ONLY = `self.addEventListener('push', (e) => {
});
self.addEventListener('notificationclick', (e) => {
e.notification.close();
+ const d = (e.notification && e.notification.data) || {};
e.waitUntil((async () => {
const all = await self.clients.matchAll({ type: 'window', includeUncontrolled: true });
const open = all.find((c) => 'focus' in c);
- if (open) return open.focus();
- if (self.clients.openWindow) return self.clients.openWindow('./');
+ if (open) {
+ if (d.view) { try { open.postMessage({ type: 'open', view: d.view }); } catch (_) {} }
+ return open.focus();
+ }
+ if (self.clients.openWindow) return self.clients.openWindow(d.url || './');
})());
});`;