[web] provide serviceWorkerVersion to the getNewServiceWorker function (#131240)

Fixes https://github.com/flutter/flutter/issues/130212

Fix `Unresolved variable or type 'serviceWorkerVersion'` in the `_getNewServiceWorker` function.  

Supersedes https://github.com/flutter/flutter/pull/130206
This commit is contained in:
Pavel Mazhnik
2023-09-15 00:17:08 +02:00
committed by GitHub
parent 98bee6777d
commit 783f2f4830
4 changed files with 182 additions and 2 deletions

View File

@@ -144,7 +144,7 @@ _flutter.loader = null;
const serviceWorkerActivation = navigator.serviceWorker
.register(url)
.then(this._getNewServiceWorker)
.then((serviceWorkerRegistration) => this._getNewServiceWorker(serviceWorkerRegistration, serviceWorkerVersion))
.then(this._waitForServiceWorkerActivation);
// Timeout race promise
@@ -162,9 +162,10 @@ _flutter.loader = null;
* awaiting to be installed/updated.
*
* @param {ServiceWorkerRegistration} serviceWorkerRegistration
* @param {String} serviceWorkerVersion
* @returns {Promise<ServiceWorker>}
*/
async _getNewServiceWorker(serviceWorkerRegistration) {
async _getNewServiceWorker(serviceWorkerRegistration, serviceWorkerVersion) {
if (!serviceWorkerRegistration.active && (serviceWorkerRegistration.installing || serviceWorkerRegistration.waiting)) {
// No active web worker and we have installed or are installing
// one for the first time. Simply wait for it to activate.