fix: SW-killer script in index.html — auto-unregister stale Service Worker
CI / lint (push) Failing after 24s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / e2e (push) Has been skipped
CI / security (push) Failing after 12s

The SW was the root cause of all persistent French text issues.
Even after rebuild, browsers with a registered SW would serve
cached old files (viewer.js without data-i18n, old locale JSONs).

SW-killer runs before any module script:
1. Detects if SW is controlling the page
2. Unregisters all SW registrations
3. Clears all caches
4. Reloads the page once (sessionStorage flag to prevent loop)

Other fixes in this commit:
- auth.js: import setLocale statically (was dynamic import)
- auth.js: import loadVaults/loadTags from sidebar.js
- sw.js: add JS modules + locales to STATIC_ASSETS for versioning
- sw.js: CACHE_VERSION v4→v5
This commit is contained in:
2026-06-21 23:12:45 -04:00
parent 72622f3dfb
commit cc22ffe6df
2 changed files with 5 additions and 2 deletions
+4
View File
@@ -4651,6 +4651,10 @@ curl -X POST https://votre-serveur.com/webhook \
<div class="find-error" id="find-error" hidden></div>
</div>
<script>
// Force-kill stale Service Worker and reload fresh
(function(){if('serviceWorker'in navigator&&navigator.serviceWorker.controller){var reloaded=sessionStorage.getItem('_sw_killed');if(!reloaded){navigator.serviceWorker.getRegistrations().then(function(regs){regs.forEach(function(r){r.unregister()})});caches.keys().then(function(names){names.forEach(function(n){caches.delete(n)})});sessionStorage.setItem('_sw_killed','1');location.reload(true)}}else{sessionStorage.removeItem('_sw_killed')}})();
</script>
<script type="module" src="/static/js/app.js"></script>
<!-- ── Mobile Bottom Toolbar ── -->
+1 -2
View File
@@ -2,7 +2,7 @@
import { state } from './state.js';
import { safeCreateIcons } from './utils.js';
import { showToast, closeHeaderMenu } from './ui.js';
import { t, getLocale } from './i18n.js';
import { t, getLocale, setLocale } from './i18n.js';
import { showWelcome } from './viewer.js';
import { loadVaults, loadTags } from './sidebar.js';
@@ -310,7 +310,6 @@ function initLoginForm() {
if (resp.ok) {
const user = await resp.json();
if (user.language && user.language !== getLocale()) {
const { setLocale } = await import('./i18n.js');
await setLocale(user.language);
}
}