mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 11:36:24 +01:00
Extract into function
This commit is contained in:
parent
3941b7e3f0
commit
d292e1f5ad
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user