Add ICS import/export with course linking, QR sync improvements, and UI polish

- Group imported ICS occurrences per weekly slot, hatch irregular/half-semester
  sessions, and link them to existing courses by stable code (not name, since
  university exports mix languages) with a one-time manual-match fallback
- Preserve exact per-date occurrences from imported ICS so exported calendars
  correctly skip holiday/vacation gaps instead of assuming a flat weekly rule
- Add "Export ICS" for a semester's course + manual schedule, prompting once
  for semester start/end dates (now also editable directly on the semester)
- Fix pinned QRCode CDN version (package dropped its browser bundle) and add
  a send/receive choice after scanning instead of always auto two-way syncing
- Fix course save silently adding a phantom Monday slot from picker defaults;
  replace with an explicit "No fixed schedule / Has a weekly schedule" toggle
- Service worker: network-first app shell so edits show up without manual
  cache-busting, self-update + reload on new worker, version indicator
- Dashboard: fold older semesters by default and jump to the current one,
  optional auto-fold for validated blocks/sub-blocks, JSON backup nudge

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-24 11:39:50 +02:00
co-authored by Claude Sonnet 5
parent fb87091b78
commit eb7e64ee06
6 changed files with 725 additions and 187 deletions
+72 -48
View File
@@ -1,48 +1,72 @@
const CACHE_NAME = 'credittracker-v36';
const ASSETS = [
'./index.html',
'./manifest.json',
'./icon.svg',
'./icon-maskable.svg'
];
// Install: pre-cache all app shell files
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS))
);
self.skipWaiting();
});
// Activate: clean up old caches
self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(keys =>
Promise.all(keys.filter(k => k !== CACHE_NAME).map(k => caches.delete(k)))
)
);
self.clients.claim();
});
// Fetch: cache-first for app files, network-first for everything else
self.addEventListener('fetch', event => {
// Only handle same-origin GET requests
if (event.request.method !== 'GET') return;
event.respondWith(
caches.match(event.request).then(cached => {
if (cached) return cached;
return fetch(event.request).then(response => {
// Cache successful responses for app assets
if (response.ok) {
const clone = response.clone();
caches.open(CACHE_NAME).then(cache => cache.put(event.request, clone));
}
return response;
});
}).catch(() => {
// Offline fallback: return the app shell
return caches.match('./index.html');
})
);
});
const CACHE_NAME = 'credittracker-v47';
const ASSETS = [
'./index.html',
'./manifest.json',
'./icon.svg',
'./icon-maskable.svg'
];
// Install: pre-cache all app shell files
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS))
);
self.skipWaiting();
});
// Activate: clean up old caches
self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(keys =>
Promise.all(keys.filter(k => k !== CACHE_NAME).map(k => caches.delete(k)))
)
);
self.clients.claim();
});
// Lets the page ask "what version are you actually running" (Settings screen indicator)
self.addEventListener('message', event => {
if (event.data && event.data.type === 'GET_VERSION') {
event.source.postMessage({ type: 'VERSION', version: CACHE_NAME });
}
});
// Fetch: network-first for the app shell (so edits show up without a version bump),
// cache-first for everything else (icons, manifest, external libs)
self.addEventListener('fetch', event => {
if (event.request.method !== 'GET') return;
const reqUrl = new URL(event.request.url);
const isSameOrigin = reqUrl.origin === self.location.origin;
const isAppShell = isSameOrigin && (event.request.mode === 'navigate' || reqUrl.pathname.endsWith('/index.html'));
if (isAppShell) {
event.respondWith(
fetch(event.request).then(response => {
if (response.ok) {
const clone = response.clone();
caches.open(CACHE_NAME).then(cache => cache.put(event.request, clone));
}
return response;
}).catch(() => caches.match(event.request).then(cached => cached || caches.match('./index.html')))
);
return;
}
event.respondWith(
caches.match(event.request).then(cached => {
if (cached) return cached;
return fetch(event.request).then(response => {
if (response.ok && isSameOrigin) {
const clone = response.clone();
caches.open(CACHE_NAME).then(cache => cache.put(event.request, clone));
}
return response;
});
}).catch(() => {
// Offline fallback only for external CDN fetches: fail loudly instead of masking with app HTML
if (isSameOrigin) return caches.match('./index.html');
return Response.error();
})
);
});