Notify from the installed web app when a generation finishes.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(self.skipWaiting())
|
||||
})
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
event.waitUntil(self.clients.claim())
|
||||
})
|
||||
|
||||
self.addEventListener('notificationclick', (event) => {
|
||||
event.notification.close()
|
||||
event.waitUntil((async () => {
|
||||
const windows = await self.clients.matchAll({ type: 'window', includeUncontrolled: true })
|
||||
for (const client of windows) {
|
||||
if ('focus' in client) return client.focus()
|
||||
}
|
||||
if (self.clients.openWindow) return self.clients.openWindow('/')
|
||||
})())
|
||||
})
|
||||
Reference in New Issue
Block a user