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() {
|
||||
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 => {
|
||||
this._composerVM = this.disposeTracked(this._composerVM);
|
||||
if (newCanSendMessage) {
|
||||
|
@ -80,8 +81,8 @@ export class RoomViewModel extends ViewModel {
|
|||
}
|
||||
this.emitChange("powerLevelObservable")
|
||||
};
|
||||
this.track(powerLevelObservable.subscribe(newPowerLevel => {
|
||||
const newCanSendMessage = newPowerLevel.canSendType("m.room.message");
|
||||
this.track(powerLevelObservable.subscribe(() => {
|
||||
const newCanSendMessage = canSendMessage();
|
||||
if (oldCanSendMessage !== newCanSendMessage) {
|
||||
recreateComposer(newCanSendMessage);
|
||||
oldCanSendMessage = newCanSendMessage;
|
||||
|
|
Reference in a new issue