fixed refreshing of tablet app

This commit is contained in:
2025-08-05 15:37:17 +02:00
parent 41a25258e5
commit 3ac0e03424
2 changed files with 15 additions and 20 deletions
@@ -502,14 +502,15 @@ Vue.component('warehouse-shipping-note', {
}
})
window.addEventListener('DOMContentLoaded', () => {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/WarehouseShippingNote/sw', {scope: '/'})
.then(registration => {
console.log('Patching PWA Service Worker registered with scope:', registration.scope);
})
.catch(error => {
console.error('Patching PWA Service Worker registration failed:', error);
});
let hiddenTime = null;
const RELOAD_AFTER_SECONDS = 300;
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
hiddenTime = new Date();
} else if (document.visibilityState === 'visible' && hiddenTime) {
const secondsElapsed = (new Date() - hiddenTime) / 1000;
if (secondsElapsed > RELOAD_AFTER_SECONDS) {
window.location.reload();
}
}
})
});