Try to reduce WidgetStore causing downstream problems
This commit is contained in:
parent
f8fe454c59
commit
29780d902c
2 changed files with 14 additions and 5 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue