mirror of
https://github.com/efiten/coredrive-rx.git
synced 2026-12-01 08:48:21 +00:00
- Connect/Disconnect (+ progress + status) moves from Home to the Settings tab, so the recently-heard list moves up — Home stays a pure monitor. - The app opens on Settings (where Connect lives) until a companion is connected, then jumps to Home; the live monitor is shown only when there's something to watch. - Last reception shows the resolved node name when available, upgrading from the raw ID once names.js resolves it (label derived live each tick). SW cache v8→v9. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
1010 B
JavaScript
26 lines
1010 B
JavaScript
// Minimal service worker: makes the app installable and lets the shell load
|
|
// offline. Network-first (always fresh online), cache fallback (offline).
|
|
// Only the static app assets go through fetch; MQTT runs over WSS (not cached).
|
|
const CACHE = 'coredrive-rx-v9';
|
|
|
|
self.addEventListener('install', () => self.skipWaiting());
|
|
self.addEventListener('activate', (e) => e.waitUntil((async () => {
|
|
// Drop stale caches from older builds so a fresh index.html is never shadowed.
|
|
const keys = await caches.keys();
|
|
await Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)));
|
|
await self.clients.claim();
|
|
})()));
|
|
|
|
self.addEventListener('fetch', (e) => {
|
|
if (e.request.method !== 'GET') return;
|
|
e.respondWith(
|
|
fetch(e.request)
|
|
.then((res) => {
|
|
const copy = res.clone();
|
|
caches.open(CACHE).then((c) => c.put(e.request, copy)).catch(() => {});
|
|
return res;
|
|
})
|
|
.catch(() => caches.match(e.request).then((m) => m || caches.match('/')))
|
|
);
|
|
});
|