diff options
| author | Adam Soltys <[email protected]> | 2026-03-06 23:36:48 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-06 23:36:48 -0800 |
| commit | c36c3c5342682eaee9a5a135e255686ce40bfc3c (patch) | |
| tree | aee881450367c779c9c2060e0944075941cdcd38 | |
| parent | 2c0782226f9841b3a4ce91bec95824f68a8c74ec (diff) | |
| download | coinos-ui-c36c3c5342682eaee9a5a135e255686ce40bfc3c.tar.gz coinos-ui-c36c3c5342682eaee9a5a135e255686ce40bfc3c.zip | |
reuse existing tab on notification click, fallback to new tab
Co-Authored-By: Claude Opus 4.6 <[email protected]>
| -rw-r--r-- | src/service-worker.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/service-worker.js b/src/service-worker.js index b4c576ba..43f0b60b 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -130,5 +130,12 @@ self.addEventListener("notificationclick", (event) => { const path = event.notification.data.url || "/"; const target = new URL(path, self.location.origin).href; - event.waitUntil(clients.openWindow(target)); + event.waitUntil( + clients.matchAll({ type: "window" }).then((clientList) => { + for (const client of clientList) { + return client.navigate(target).then(() => client.focus()); + } + return clients.openWindow(target); + }), + ); }); |
