From 0fb09cc431474ac00fc9fe5e69e7a8122b479380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 6 Jan 2022 12:27:00 +0100 Subject: [PATCH] Fixing closing of all websites. --- front/src/WebRtc/CoWebsiteManager.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/front/src/WebRtc/CoWebsiteManager.ts b/front/src/WebRtc/CoWebsiteManager.ts index 8bff2acb..48cc9680 100644 --- a/front/src/WebRtc/CoWebsiteManager.ts +++ b/front/src/WebRtc/CoWebsiteManager.ts @@ -612,17 +612,16 @@ class CoWebsiteManager { } } - public closeCoWebsites(): Promise { - this.currentOperationPromise = this.currentOperationPromise.then(() => { - const promises: Promise[] = []; - this.coWebsites.forEach((coWebsite: CoWebsite) => { - promises.push(this.closeCoWebsite(coWebsite)); - }); - return Promise.all(promises).then(() => { - return; - }); + public async closeCoWebsites(): Promise { + await this.currentOperationPromise; + + const promises: Promise[] = []; + this.coWebsites.forEach((coWebsite: CoWebsite) => { + promises.push(this.closeCoWebsite(coWebsite)); }); - return this.currentOperationPromise; + await Promise.all(promises); + // TODO: this.currentOperationPromise does not point any more on the last promise + return; } public getGameSize(): { width: number; height: number } {