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

Prevent refreshing on initial install #5536

Merged
merged 2 commits into from Jan 2, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -2,7 +2,7 @@ project_path: /web/tools/workbox/_project.yaml
book_path: /web/tools/workbox/_book.yaml
description: Advanced recipes to use with Workbox.
{# wf_updated_on: 2017-12-17 #}
{# wf_updated_on: 2017-12-19 #}
{# wf_published_on: 2017-12-17 #}
{# wf_blink_components: N/A #}
@@ -72,12 +72,6 @@ function onNewServiceWorker(registration, callback) {
}
window.addEventListener('load', function() {
// When the user asks to refresh the UI, we'll need to reload the window
navigator.serviceWorker.addEventListener('controllerchange', function(event) {
console.log('Controller loaded');
window.location.reload();
});
navigator.serviceWorker.register('/sw.js')
.then(function (registration) {
// Track updates to the Service Worker.
@@ -87,6 +81,17 @@ window.addEventListener('load', function() {
return;
}
// When the user asks to refresh the UI, we'll need to reload the window
var preventDevToolsReloadLoop;
navigator.serviceWorker.addEventListener('controllerchange', function(event) {
// Ensure refresh is only called once.
// This works around a bug in "force update on reload".
if (preventDevToolsReloadLoop) return;
preventDevToolsReloadLoop = true;
console.log('Controller loaded');
window.location.reload();
});
onNewServiceWorker(registration, function() {
showRefreshUI(registration);
});
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.