ForceReload: update service worker refresh logic (#6162)

This commit is contained in:
Matiss Janis Aboltins
2025-11-16 21:11:41 +00:00
committed by GitHub
parent 1ce2280a49
commit de04af9ff0
2 changed files with 16 additions and 8 deletions

View File

@@ -96,17 +96,19 @@ export function ForceReload() {
async function onForceReload() {
setReloading(true);
try {
if (isElectron()) {
window.location.reload();
} else {
if (window.Actual?.applyAppUpdate) {
await window.Actual.applyAppUpdate();
} else {
window.location.reload();
if (!isElectron()) {
const registration =
await window.navigator.serviceWorker.getRegistration('/');
if (registration) {
await registration.update();
if (registration.waiting) {
registration.waiting.postMessage({ type: 'SKIP_WAITING' });
}
}
}
} catch (error) {
// If reload fails, fall back to location.reload()
// Do nothing
} finally {
window.location.reload();
}
}

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---
Force reload: update logic for service worker data refresh