mirror of https://github.com/vector-im/riot-web
Try to reduce WidgetStore causing downstream problems
parent
f8fe454c59
commit
29780d902c
|
@ -76,7 +76,7 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
|
|||
this.matrixClient.getRooms().forEach((room: Room) => {
|
||||
this.loadRoomWidgets(room);
|
||||
});
|
||||
this.emit(UPDATE_EVENT);
|
||||
this.emit(UPDATE_EVENT, null); // emit for all rooms
|
||||
}
|
||||
|
||||
protected async onNotReady(): Promise<any> {
|
||||
|
@ -94,7 +94,7 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
|
|||
private onWidgetEchoStoreUpdate = (roomId: string, widgetId: string) => {
|
||||
this.initRoom(roomId);
|
||||
this.loadRoomWidgets(this.matrixClient.getRoom(roomId));
|
||||
this.emit(UPDATE_EVENT);
|
||||
this.emit(UPDATE_EVENT, roomId);
|
||||
};
|
||||
|
||||
private generateApps(room: Room): IApp[] {
|
||||
|
@ -143,7 +143,7 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
|
|||
const roomId = ev.getRoomId();
|
||||
this.initRoom(roomId);
|
||||
this.loadRoomWidgets(this.matrixClient.getRoom(roomId));
|
||||
this.emit(UPDATE_EVENT);
|
||||
this.emit(UPDATE_EVENT, roomId);
|
||||
};
|
||||
|
||||
public getRoom = (roomId: string) => {
|
||||
|
|
|
@ -131,7 +131,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
|||
this.matrixClient.on("RoomState.events", this.updateRoomFromState);
|
||||
this.pinnedRef = SettingsStore.watchSetting("Widgets.pinned", null, this.updateFromSettings);
|
||||
this.layoutRef = SettingsStore.watchSetting("Widgets.layout", null, this.updateFromSettings);
|
||||
WidgetStore.instance.on(UPDATE_EVENT, this.updateAllRooms);
|
||||
WidgetStore.instance.on(UPDATE_EVENT, this.updateFromWidgetStore);
|
||||
}
|
||||
|
||||
protected async onNotReady(): Promise<any> {
|
||||
|
@ -139,7 +139,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
|||
|
||||
SettingsStore.unwatchSetting(this.pinnedRef);
|
||||
SettingsStore.unwatchSetting(this.layoutRef);
|
||||
WidgetStore.instance.off(UPDATE_EVENT, this.updateAllRooms);
|
||||
WidgetStore.instance.off(UPDATE_EVENT, this.updateFromWidgetStore);
|
||||
}
|
||||
|
||||
private updateAllRooms = () => {
|
||||
|
@ -149,6 +149,15 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
|||
}
|
||||
};
|
||||
|
||||
private updateFromWidgetStore = (roomId?:string) => {
|
||||
if (roomId) {
|
||||
const room = this.matrixClient.getRoom(roomId);
|
||||
if (room) this.recalculateRoom(room);
|
||||
} else {
|
||||
this.updateAllRooms();
|
||||
}
|
||||
};
|
||||
|
||||
private updateRoomFromState = (ev: MatrixEvent) => {
|
||||
if (ev.getType() !== WIDGET_LAYOUT_EVENT_TYPE) return;
|
||||
const room = this.matrixClient.getRoom(ev.getRoomId());
|
||||
|
|
Loading…
Reference in New Issue