Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a no-op service worker for previous installations #7

Merged
merged 1 commit into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions website/static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ window.addEventListener('load', function() {
clipboard.on('success', function(event) {
event.clearSelection();
})
navigator.serviceWorker.register('/service-worker.js');
})

function setpp(event) {
Expand Down
22 changes: 22 additions & 0 deletions website/static/service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// A simple, no-op service worker that takes immediate control.

self.addEventListener('install', () => {
// Skip over the "waiting" lifecycle state, to ensure that our
// new service worker is activated immediately, even if there's
// another tab open controlled by our older service worker code.
self.skipWaiting();
});

/*
self.addEventListener('activate', () => {
// Optional: Get a list of all the current open windows/tabs under
// our service worker's control, and force them to reload.
// This can "unbreak" any open windows/tabs as soon as the new
// service worker activates, rather than users having to manually reload.
self.clients.matchAll({type: 'window'}).then(windowClients => {
windowClients.forEach(windowClient => {
windowClient.navigate(windowClient.url);
});
});
});
*/