From 8e39aed4b6fe6db239af69a1a3c944a8a934eb59 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Wed, 14 Jul 2021 14:32:39 +0530 Subject: [PATCH] Ensure that power levels are loaded only once Signed-off-by: RMidhunSuresh --- src/matrix/room/BaseRoom.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/matrix/room/BaseRoom.js b/src/matrix/room/BaseRoom.js index 7f5992ee..bcb8141f 100644 --- a/src/matrix/room/BaseRoom.js +++ b/src/matrix/room/BaseRoom.js @@ -414,11 +414,14 @@ export class BaseRoom extends EventEmitter { } async observePowerLevels() { + if (this._powerLevelLoading) { await this._powerLevelLoading; } let observable = this._powerLevels; if (!observable) { - const powerLevels = await this._loadPowerLevels(); + this._powerLevelLoading = this._loadPowerLevels(); + const powerLevels = await this._powerLevelLoading; observable = new RetainedObservableValue(powerLevels, () => { this._powerLevels = null; }); this._powerLevels = observable; + this._powerLevelLoading = null; } return observable; }