Merge pull request #5564 from matrix-org/travis/fosdem/layout-fixes-2
Update widgets in the room upon join
This commit is contained in:
commit
fe4af4fb90
1 changed files with 8 additions and 0 deletions
|
@ -72,6 +72,7 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async onReady(): Promise<any> {
|
protected async onReady(): Promise<any> {
|
||||||
|
this.matrixClient.on("Room", this.onRoom);
|
||||||
this.matrixClient.on("RoomState.events", this.onRoomStateEvents);
|
this.matrixClient.on("RoomState.events", this.onRoomStateEvents);
|
||||||
this.matrixClient.getRooms().forEach((room: Room) => {
|
this.matrixClient.getRooms().forEach((room: Room) => {
|
||||||
this.loadRoomWidgets(room);
|
this.loadRoomWidgets(room);
|
||||||
|
@ -80,6 +81,7 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async onNotReady(): Promise<any> {
|
protected async onNotReady(): Promise<any> {
|
||||||
|
this.matrixClient.off("Room", this.onRoom);
|
||||||
this.matrixClient.off("RoomState.events", this.onRoomStateEvents);
|
this.matrixClient.off("RoomState.events", this.onRoomStateEvents);
|
||||||
this.widgetMap = new Map();
|
this.widgetMap = new Map();
|
||||||
this.roomMap = new Map();
|
this.roomMap = new Map();
|
||||||
|
@ -138,6 +140,12 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
|
||||||
this.emit(room.roomId);
|
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) => {
|
private onRoomStateEvents = (ev: MatrixEvent) => {
|
||||||
if (ev.getType() !== "im.vector.modular.widgets") return; // TODO: Support m.widget too
|
if (ev.getType() !== "im.vector.modular.widgets") return; // TODO: Support m.widget too
|
||||||
const roomId = ev.getRoomId();
|
const roomId = ev.getRoomId();
|
||||||
|
|
Loading…
Reference in a new issue