Skip to content

Commit

Permalink
Use service worker version template token
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebQ42 committed May 21, 2024
1 parent ba07401 commit a51b0bf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
var serviceWorkerVersion = null;
var scriptLoaded = false;
function loadMainDartJs() {
if (scriptLoaded) {
Expand All @@ -62,7 +61,7 @@
// Wait for registration to finish before dropping the <script> tag.
// Otherwise, the browser will load the script multiple times,
// potentially different versions.
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + {{flutter_service_worker_version}};
navigator.serviceWorker.register(serviceWorkerUrl)
.then((reg) => {
function waitForActivation(serviceWorker) {
Expand All @@ -77,7 +76,7 @@
// No active web worker and we have installed or are installing
// one for the first time. Simply wait for it to activate.
waitForActivation(reg.installing || reg.waiting);
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
} else if (!reg.active.scriptURL.endsWith({{flutter_service_worker_version}})) {
// When the app updates the serviceWorkerVersion changes, so we
// need to ask the service worker to update.
console.log('New service worker available.');
Expand Down

0 comments on commit a51b0bf

Please sign in to comment.