509b1a1320
Tasks can now have a start/end time on their deadline date. The new Calendar view shows a day as a timeline (with a week strip and projected repeats of recurring tasks), and the task form lists what is already planned that day and flags overlaps. Existing databases are migrated to schema v2 automatically, with a backup copy taken first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
// Network-first service worker: always fresh when online, app shell still opens offline.
|
|
const CACHE = 'whattodo-v2';
|
|
const SHELL = [
|
|
'./', 'index.html', 'style.css', 'app.js', 'manifest.webmanifest',
|
|
'icons/icon.svg', 'icons/icon-192.png', 'icons/icon-512.png',
|
|
];
|
|
|
|
self.addEventListener('install', (event) => {
|
|
event.waitUntil(caches.open(CACHE).then((c) => c.addAll(SHELL)).then(() => self.skipWaiting()));
|
|
});
|
|
|
|
self.addEventListener('activate', (event) => {
|
|
event.waitUntil(
|
|
caches.keys()
|
|
.then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k))))
|
|
.then(() => self.clients.claim()),
|
|
);
|
|
});
|
|
|
|
self.addEventListener('fetch', (event) => {
|
|
const req = event.request;
|
|
const url = new URL(req.url);
|
|
if (req.method !== 'GET' || url.origin !== self.location.origin || url.pathname.includes('/api/')) return;
|
|
event.respondWith(
|
|
fetch(req)
|
|
.then((res) => {
|
|
if (res.ok) {
|
|
const copy = res.clone();
|
|
caches.open(CACHE).then((c) => c.put(req, copy));
|
|
}
|
|
return res;
|
|
})
|
|
.catch(() => caches.match(req).then((hit) => hit || caches.match('index.html'))),
|
|
);
|
|
});
|