Auf schmalen Screens saß der Marker-Modus-Button bisher nur in der 150px- Randspalte — man musste sie erst öffnen (und damit den ohnehin knappen Lesebereich verkleinern), um überhaupt markieren zu können. Jetzt zusätzlich ein Marker-Button direkt im Haupt-Header (nur <=600px sichtbar, Desktop bleibt bei der bisherigen Anordnung in der Notes-Leiste). Im Marker-Modus legt ein einfacher Tap auf reinen Lesetext (ohne Auswahl) jetzt direkt eine freie Notiz an der Wortposition an — man muss nicht mehr den exakten Klick-Punkt in der Randspalte treffen. Das Bearbeiten der Notiz läuft auf schmalen Viewports über ein neues Bottom-Sheet (volle Breite) statt über das Inline-Textfeld in der 150px-Spalte, das auf dem Handy-Keyboard unangenehm zu bedienen ist. Notiz-Objekte werden jetzt erst bei tatsächlich eingegebenem Text angelegt und gespeichert (vorher: sofort beim Setzen des Ankers) — verhindert, dass ein abgebrochener/leerer Tap eine Ghost-Notiz in currentHighlights hinterlässt. Gilt für alle Eingabewege (Bottom-Sheet UND die bestehende Inline-Randspalten-Bearbeitung), per Playwright verifiziert inkl. Escape- Cancel auf Desktop. Priorität laut Nutzer: Notizen-Erfassung muss auf Mobile gut funktionieren; dass bestehende Notizen dort weniger prominent sichtbar sind, ist explizit in Ordnung — die vertiefte Auseinandersetzung mit Notizen bleibt eine Desktop-Aufgabe. Verifiziert per Playwright (390×844 mobil + 1280×900 Desktop-Regression): Marker-Button-Sichtbarkeit, Bottom-Sheet-Flow (Erstellen/Abbrechen/Speichern, kein Ghost-Eintrag), reale Text-Selektion + Highlight+Notiz weiterhin funktionsfähig auf Mobile, Desktop-Workflow (Randspalte, Inline-Editor, Escape-Cancel, Blur-Commit) unverändert. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
107 lines
3.3 KiB
JavaScript
107 lines
3.3 KiB
JavaScript
/**
|
|
* diora service worker — caches the app shell for offline use.
|
|
*/
|
|
|
|
const CACHE = 'diora-v32';
|
|
const PODCAST_CACHE = 'diora-podcast-v1';
|
|
const SHELL = [
|
|
'/static/css/app.css',
|
|
'/static/js/app.js',
|
|
'/static/manifest.json',
|
|
];
|
|
|
|
// Install: pre-cache the app shell
|
|
self.addEventListener('install', function (event) {
|
|
event.waitUntil(
|
|
caches.open(CACHE).then(function (cache) {
|
|
return cache.addAll(SHELL);
|
|
})
|
|
);
|
|
// Activate immediately without waiting for old tabs to close
|
|
self.skipWaiting();
|
|
});
|
|
|
|
// Activate: remove stale caches from previous versions
|
|
self.addEventListener('activate', function (event) {
|
|
event.waitUntil(
|
|
caches.keys().then(function (keys) {
|
|
return Promise.all(
|
|
keys.filter(function (key) { return key !== CACHE && key !== PODCAST_CACHE; })
|
|
.map(function (key) { return caches.delete(key); })
|
|
);
|
|
}).then(function () {
|
|
return self.clients.claim();
|
|
}).then(function () {
|
|
// Tell all open tabs to reload so they get the latest cached assets
|
|
return self.clients.matchAll({type: 'window'}).then(function (clients) {
|
|
clients.forEach(function (client) {
|
|
client.postMessage({type: 'SW_ACTIVATED'});
|
|
});
|
|
});
|
|
})
|
|
);
|
|
});
|
|
|
|
// Fetch: serve from cache, fall back to network
|
|
self.addEventListener('fetch', function (event) {
|
|
// Only handle GET requests; let POST/SSE etc. pass through
|
|
if (event.request.method !== 'GET') return;
|
|
|
|
const url = new URL(event.request.url);
|
|
|
|
// Bypass for API/mutation endpoints
|
|
if (url.pathname.startsWith('/radio/sse/') ||
|
|
url.pathname.startsWith('/radio/record/') ||
|
|
url.pathname.startsWith('/radio/affiliate/') ||
|
|
url.pathname.startsWith('/admin/') ||
|
|
url.pathname.startsWith('/podcasts/progress/') ||
|
|
url.pathname.startsWith('/podcasts/queue/') ||
|
|
url.pathname === '/podcasts/feeds/add' ||
|
|
url.pathname.startsWith('/podcasts/feeds/add') ||
|
|
url.pathname.includes('/remove') ||
|
|
url.pathname.startsWith('/podcasts/feeds/refresh')) {
|
|
return;
|
|
}
|
|
|
|
// Podcast audio: serve from podcast cache first, then network
|
|
if (event.request.destination === 'audio') {
|
|
event.respondWith(
|
|
caches.open(PODCAST_CACHE).then(function (cache) {
|
|
return cache.match(event.request).then(function (cached) {
|
|
if (cached) return cached;
|
|
return fetch(event.request).then(function (response) {
|
|
return response;
|
|
});
|
|
});
|
|
})
|
|
);
|
|
return;
|
|
}
|
|
|
|
// Cache-first for pre-defined shell assets
|
|
const isShell = SHELL.some(function (s) { return url.pathname === s; });
|
|
if (isShell) {
|
|
event.respondWith(
|
|
caches.match(event.request).then(function (cached) {
|
|
return cached || fetch(event.request);
|
|
})
|
|
);
|
|
return;
|
|
}
|
|
|
|
// Navigation requests (the HTML page itself): network-first, fall back to
|
|
// last cached version so the app opens offline after being visited once.
|
|
if (event.request.mode === 'navigate') {
|
|
event.respondWith(
|
|
fetch(event.request).then(function (response) {
|
|
if (response.ok) {
|
|
var clone = response.clone();
|
|
caches.open(CACHE).then(function (cache) { cache.put(event.request, clone); });
|
|
}
|
|
return response;
|
|
}).catch(function () {
|
|
return caches.match(event.request);
|
|
})
|
|
);
|
|
}
|
|
});
|