deregistering the warehouseshippingnote serviceworker
This commit is contained in:
@@ -794,30 +794,40 @@ class WarehouseShippingNoteController extends TTCrud {
|
||||
self::returnJson($logs);
|
||||
}
|
||||
|
||||
protected function swAction() {
|
||||
$javascript = "self.addEventListener('install', event => {
|
||||
console.log('Patching PWA Service Worker: Installing...');
|
||||
protected function swAction() {
|
||||
// This script's only job is to unregister the service worker.
|
||||
$javascript = "
|
||||
self.addEventListener('install', event => {
|
||||
// Take control immediately so we can proceed to the 'activate' step.
|
||||
self.skipWaiting();
|
||||
console.log('Deregistering PWA Service Worker: Installing...');
|
||||
});
|
||||
|
||||
self.addEventListener('activate', event => {
|
||||
console.log('Patching PWA Service Worker: Activating...');
|
||||
});
|
||||
console.log('Deregistering PWA Service Worker: Activating...');
|
||||
|
||||
// The main command to unregister the service worker.
|
||||
self.registration.unregister()
|
||||
.then(() => {
|
||||
// After unregistering, get a list of all clients (open tabs/windows).
|
||||
return self.clients.matchAll();
|
||||
})
|
||||
.then(clients => {
|
||||
// Reload all clients to ensure they are no longer controlled by the SW.
|
||||
clients.forEach(client => client.navigate(client.url));
|
||||
console.log('Service worker has been successfully deregistered.');
|
||||
});
|
||||
});";
|
||||
|
||||
self.addEventListener('fetch', event => {
|
||||
event.respondWith(fetch(event.request));
|
||||
});
|
||||
header("Content-Type: application/javascript");
|
||||
header("Service-Worker-Allowed: /");
|
||||
// Ensure the browser never caches this deregistering script.
|
||||
header("Cache-Control: no-cache, no-store, must-revalidate");
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: 0");
|
||||
|
||||
console.log('Patching PWA Service Worker: Script loaded.');";
|
||||
|
||||
header("Content-Type: application/javascript");
|
||||
header("Service-Worker-Allowed: /");
|
||||
header("Cache-Control: no-cache");
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: 0");
|
||||
|
||||
echo $javascript;
|
||||
exit;
|
||||
|
||||
}
|
||||
echo $javascript;
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user