* Checks for an update and waits until the new version is downloaded from the server and ready * for activation. * * @returns a promise that * - resolves to `true` if a new version was found and is ready to be activated. * - resolves to `false` if no new version was found * - rejec
()
| 83 | * - rejects if any error occurs |
| 84 | */ |
| 85 | checkForUpdate(): Promise<boolean> { |
| 86 | if (!this.sw.isEnabled) { |
| 87 | return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED)); |
| 88 | } |
| 89 | if (this.ongoingCheckForUpdate) { |
| 90 | return this.ongoingCheckForUpdate; |
| 91 | } |
| 92 | const nonce = this.sw.generateNonce(); |
| 93 | this.ongoingCheckForUpdate = this.sw |
| 94 | .postMessageWithOperation('CHECK_FOR_UPDATES', {nonce}, nonce) |
| 95 | .finally(() => { |
| 96 | this.ongoingCheckForUpdate = null; |
| 97 | }); |
| 98 | return this.ongoingCheckForUpdate; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Updates the current client (i.e. browser tab) to the latest version that is ready for |
no test coverage detected