Update widgets in the room upon join

pull/21833/head
Travis Ralston 2021-01-22 17:49:18 -07:00
parent 2af14cde42
commit d3281db2bf
1 changed files with 8 additions and 0 deletions

View File

@ -72,6 +72,7 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
}
protected async onReady(): Promise<any> {
this.matrixClient.on("Room", this.onRoom);
this.matrixClient.on("RoomState.events", this.onRoomStateEvents);
this.matrixClient.getRooms().forEach((room: Room) => {
this.loadRoomWidgets(room);
@ -80,6 +81,7 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
}
protected async onNotReady(): Promise<any> {
this.matrixClient.off("Room", this.onRoom);
this.matrixClient.off("RoomState.events", this.onRoomStateEvents);
this.widgetMap = new Map();
this.roomMap = new Map();
@ -138,6 +140,12 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
this.emit(room.roomId);
}
private onRoom = (room: Room) => {
this.initRoom(room.roomId);
this.loadRoomWidgets(room);
this.emit(UPDATE_EVENT, room.roomId);
};
private onRoomStateEvents = (ev: MatrixEvent) => {
if (ev.getType() !== "im.vector.modular.widgets") return; // TODO: Support m.widget too
const roomId = ev.getRoomId();