forked from mystiq/hydrogen-web
Extract into function
This commit is contained in:
parent
3941b7e3f0
commit
d292e1f5ad
1 changed files with 4 additions and 3 deletions
|
@ -69,7 +69,8 @@ export class RoomViewModel extends ViewModel {
|
||||||
|
|
||||||
async _recreateComposerOnPowerLevelChange() {
|
async _recreateComposerOnPowerLevelChange() {
|
||||||
const powerLevelObservable = await this._room.observePowerLevels();
|
const powerLevelObservable = await this._room.observePowerLevels();
|
||||||
let oldCanSendMessage = powerLevelObservable.get().canSendType("m.room.message");
|
const canSendMessage = () => powerLevelObservable.get().canSendType("m.room.message");
|
||||||
|
let oldCanSendMessage = canSendMessage();
|
||||||
const recreateComposer = newCanSendMessage => {
|
const recreateComposer = newCanSendMessage => {
|
||||||
this._composerVM = this.disposeTracked(this._composerVM);
|
this._composerVM = this.disposeTracked(this._composerVM);
|
||||||
if (newCanSendMessage) {
|
if (newCanSendMessage) {
|
||||||
|
@ -80,8 +81,8 @@ export class RoomViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
this.emitChange("powerLevelObservable")
|
this.emitChange("powerLevelObservable")
|
||||||
};
|
};
|
||||||
this.track(powerLevelObservable.subscribe(newPowerLevel => {
|
this.track(powerLevelObservable.subscribe(() => {
|
||||||
const newCanSendMessage = newPowerLevel.canSendType("m.room.message");
|
const newCanSendMessage = canSendMessage();
|
||||||
if (oldCanSendMessage !== newCanSendMessage) {
|
if (oldCanSendMessage !== newCanSendMessage) {
|
||||||
recreateComposer(newCanSendMessage);
|
recreateComposer(newCanSendMessage);
|
||||||
oldCanSendMessage = newCanSendMessage;
|
oldCanSendMessage = newCanSendMessage;
|
||||||
|
|
Loading…
Reference in a new issue