Start the service worker before doing anything else

This commit is contained in:
Paulo Pinto 2022-12-15 14:59:43 +00:00
parent cab5fe98d1
commit 46f7a9b2a9
No known key found for this signature in database

View File

@ -144,7 +144,6 @@ export class Platform {
this._serviceWorkerHandler = null;
if (assetPaths.serviceWorker && "serviceWorker" in navigator) {
this._serviceWorkerHandler = new ServiceWorkerHandler();
this._serviceWorkerHandler.registerAndStart(assetPaths.serviceWorker);
}
this.notificationService = undefined;
// Only try to use crypto when olm is provided
@ -172,6 +171,12 @@ export class Platform {
async init() {
try {
if (this._serviceWorkerHandler instanceof ServiceWorkerHandler) {
// Start the service worker before doing anything else,
// to make sure all requests are intercepted by the service worker.
await this._serviceWorkerHandler.registerAndStart(this._assetPaths.serviceWorker)
}
await this.logger.run("Platform init", async (log) => {
if (!this._config) {
if (!this._configURL) {