fixed refreshing of tablet app
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user