Spaces:
Running
Running
File size: 697 Bytes
3170fd5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // Pick up new versions on the next launch instead of the one after: when a new
// service worker takes over, reload — unless a conversion or playback is running,
// in which case wait until it's idle.
if ('serviceWorker' in navigator) {
const hadController = !!navigator.serviceWorker.controller;
const busy = () => !document.getElementById('ex-bar')?.classList.contains('hidden')
|| !document.getElementById('audio')?.paused;
navigator.serviceWorker.addEventListener('controllerchange', () => {
if (!hadController) return; // first install: nothing stale to replace
const tryReload = () => (busy() ? setTimeout(tryReload, 3000) : location.reload());
tryReload();
});
}
|