Add real lightning overlay, push notifications, map controls, hourly summary, favorites enhancements, API resilience, UI polish

This commit is contained in:
Nate committed 2026-03-16 13:10:34 -04:00
1 parent bd3e1e9605
commit 52c96225b9
7 files changed
+909 -78

No files matched your search

+36 -1
View File
@@ -1,6 +1,6 @@
'use strict';
const CACHE = 'weather-v1';
const CACHE = 'weather-v2';
// App shell — cached on install for offline use
const PRECACHE = [
@@ -64,3 +64,38 @@ self.addEventListener('fetch', event => {
})
);
});
self.addEventListener('push', event => {
let payload = { title: 'Weather alert', body: 'New weather update available.', url: '/' };
try {
const data = event.data ? event.data.json() : null;
if (data) payload = { ...payload, ...data };
} catch {
// Ignore malformed payload and use defaults.
}
event.waitUntil(
self.registration.showNotification(payload.title, {
body: payload.body,
icon: '/icons/icon.svg',
badge: '/icons/icon.svg',
data: { url: payload.url || '/' },
})
);
});
self.addEventListener('notificationclick', event => {
event.notification.close();
const target = event.notification?.data?.url || '/';
event.waitUntil(
clients.matchAll({ type: 'window', includeUncontrolled: true }).then(windowClients => {
const existing = windowClients.find(c => c.url.includes(self.location.origin));
if (existing) {
existing.focus();
existing.navigate(target);
return;
}
return clients.openWindow(target);
})
);
});