From d7a27b188d93b72fd39d4e745a6897f2a0c394d4 Mon Sep 17 00:00:00 2001 From: marwin Date: Sat, 30 May 2026 00:19:00 +0200 Subject: [PATCH] Layout + SW: Tab-Leiste sichtbar + kein veralteter Cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - main-content padding-top auf calc(var(--nav-h) + 0.75rem) erhöht damit die Tab-Leiste (Radio/Focus/Podcasts/Books) sicher unterhalb der fixed Navbar liegt — auf Desktop und Mobile - SW v10: sendet SW_ACTIVATED an alle offenen Tabs wenn ein neuer SW übernimmt; app.js lädt daraufhin neu (außer wenn ein Buch geöffnet ist) — verhindert dass der Browser eine uralte HTTP-gecachte Version ausliefert Co-Authored-By: Claude Sonnet 4.6 --- static/css/app.css | 6 +++--- static/js/app.js | 7 +++++++ static/js/sw.js | 9 ++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/static/css/app.css b/static/css/app.css index 3eb712e..3cb6623 100644 --- a/static/css/app.css +++ b/static/css/app.css @@ -149,8 +149,8 @@ a:hover { .main-content { max-width: 1100px; margin: 0 auto; - padding: 1rem 1.5rem calc(var(--bar-h) + 2rem); - height: calc(100% - var(--nav-h)); + padding: calc(var(--nav-h) + 0.75rem) 1.5rem calc(var(--bar-h) + 2rem); + height: 100%; overflow-y: auto; } @@ -736,7 +736,7 @@ a:hover { @media (max-width: 600px) { .main-content { - padding: 0.75rem 0.75rem calc(var(--bar-h) + 1.5rem); + padding: calc(var(--nav-h) + 0.5rem) 0.75rem calc(var(--bar-h) + 1.5rem); } .now-playing-bar { diff --git a/static/js/app.js b/static/js/app.js index 48909d3..5eeb975 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -2213,6 +2213,13 @@ if ('serviceWorker' in navigator) { console.warn('Service worker registration failed:', err); }); }); + // When a new SW activates it sends SW_ACTIVATED — reload to get fresh assets, + // but only if the reader isn't open (would interrupt reading). + navigator.serviceWorker.addEventListener('message', e => { + if (e.data?.type === 'SW_ACTIVATED' && !currentBookId) { + window.location.reload(); + } + }); } // --------------------------------------------------------------------------- diff --git a/static/js/sw.js b/static/js/sw.js index aa6b47a..83d3bb8 100644 --- a/static/js/sw.js +++ b/static/js/sw.js @@ -2,7 +2,7 @@ * diora service worker — caches the app shell for offline use. */ -const CACHE = 'diora-v9'; +const CACHE = 'diora-v10'; const PODCAST_CACHE = 'diora-podcast-v1'; const SHELL = [ '/static/css/app.css', @@ -31,6 +31,13 @@ self.addEventListener('activate', function (event) { ); }).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'}); + }); + }); }) ); });