feat(notifications): add configurable browser reminders
This commit is contained in:
1 parent
349ac4fc87
commit
cf0327fcaf
14 files changed
+217
-21
No files matched your search
@@ -1,4 +1,4 @@
|
||||
const CACHE = 'life-os-shell-v1.14.2';
|
||||
const CACHE = 'life-os-shell-v1.15.0';
|
||||
const SHELL = [
|
||||
'/', '/index.html', '/manifest.webmanifest', '/life-os-icon.svg'
|
||||
];
|
||||
@@ -29,3 +29,15 @@ self.addEventListener('fetch', event => {
|
||||
return response;
|
||||
})));
|
||||
});
|
||||
|
||||
self.addEventListener('notificationclick', event => {
|
||||
event.notification.close();
|
||||
const app = ['today', 'tasks', 'system'].includes(event.notification.data?.app) ? event.notification.data.app : 'system';
|
||||
event.waitUntil(self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then(async clients => {
|
||||
const existing = clients.find(client => new URL(client.url).origin === self.location.origin);
|
||||
if (existing) {
|
||||
await existing.focus();
|
||||
existing.postMessage({ type: 'lifeos-open-app', app });
|
||||
} else await self.clients.openWindow('/?app=' + encodeURIComponent(app));
|
||||
}));
|
||||
});
|
||||
Reference in new issue
Block a user