forked from mystiq/hydrogen-web
Ensure that power levels are loaded only once
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
14c00f50fc
commit
8e39aed4b6
1 changed files with 4 additions and 1 deletions
|
@ -414,11 +414,14 @@ export class BaseRoom extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async observePowerLevels() {
|
async observePowerLevels() {
|
||||||
|
if (this._powerLevelLoading) { await this._powerLevelLoading; }
|
||||||
let observable = this._powerLevels;
|
let observable = this._powerLevels;
|
||||||
if (!observable) {
|
if (!observable) {
|
||||||
const powerLevels = await this._loadPowerLevels();
|
this._powerLevelLoading = this._loadPowerLevels();
|
||||||
|
const powerLevels = await this._powerLevelLoading;
|
||||||
observable = new RetainedObservableValue(powerLevels, () => { this._powerLevels = null; });
|
observable = new RetainedObservableValue(powerLevels, () => { this._powerLevels = null; });
|
||||||
this._powerLevels = observable;
|
this._powerLevels = observable;
|
||||||
|
this._powerLevelLoading = null;
|
||||||
}
|
}
|
||||||
return observable;
|
return observable;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue