Web: neue Version lädt erst, wenn nichts spielt; kurze Gerätenamen, sw v61
Bisher lud die Seite bei einer neuen Version sofort neu – auch mitten im Radio oder Podcast. Jetzt erst, wenn nichts spielt, kein Buch offen ist und kein Textfeld den Fokus hat. Der Browser heißt im Player-Sync kurz „Chrome · Windows“. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
262dd0d207
commit
779b54623e
3 changed files with 23 additions and 6 deletions
|
|
@ -1352,10 +1352,26 @@ if ('serviceWorker' in navigator) {
|
|||
});
|
||||
});
|
||||
// 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).
|
||||
// but never in the middle of something: not while a book is open, radio or a
|
||||
// podcast plays, or a text field has the focus — then as soon as that's over.
|
||||
let reloadPending = false;
|
||||
const busy = () => {
|
||||
if (currentBookId || isPlaying) return true;
|
||||
const host = window.DioraPodcastHost;
|
||||
if (host && host.playerState) {
|
||||
try { if (JSON.parse(host.playerState()).playing) return true; } catch (_) {}
|
||||
}
|
||||
const el = document.activeElement;
|
||||
return !!el && (el.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName));
|
||||
};
|
||||
const reloadWhenIdle = () => {
|
||||
if (busy()) setTimeout(reloadWhenIdle, 5000);
|
||||
else window.location.reload();
|
||||
};
|
||||
navigator.serviceWorker.addEventListener('message', e => {
|
||||
if (e.data?.type === 'SW_ACTIVATED' && !currentBookId) {
|
||||
window.location.reload();
|
||||
if (e.data?.type === 'SW_ACTIVATED' && !reloadPending) {
|
||||
reloadPending = true;
|
||||
reloadWhenIdle();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -937,11 +937,12 @@
|
|||
: /Chrome\//.test(ua) ? 'Chrome' : /Safari\//.test(ua) ? 'Safari' : 'Web';
|
||||
const os = /Android/.test(ua) ? 'Android' : /iPhone|iPad|iPod/.test(ua) ? 'iOS' : /Windows/.test(ua) ? 'Windows'
|
||||
: /Macintosh|Mac OS X/.test(ua) ? 'macOS' : /CrOS/.test(ua) ? 'ChromeOS' : /Linux/.test(ua) ? 'Linux' : '';
|
||||
return os ? browser + '/' + os : browser;
|
||||
return os ? browser + ' · ' + os : browser;
|
||||
}
|
||||
|
||||
const DEVICE_ID = deviceId();
|
||||
const DEVICE_NAME = 'Browser (' + browserName() + ')';
|
||||
// Short, it stands in the bar ("läuft auf Chrome · Windows").
|
||||
const DEVICE_NAME = browserName();
|
||||
|
||||
const sync = {
|
||||
state: null, // the server's state, as last taken in
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* diora service worker — caches the app shell for offline use.
|
||||
*/
|
||||
|
||||
const CACHE = 'diora-v60';
|
||||
const CACHE = 'diora-v61';
|
||||
const SHELL = [
|
||||
'/static/css/app.css',
|
||||
'/static/js/app.js',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue