Fix WidgetStore wrongly hanging onto old Widget definitions during removal

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2020-10-21 16:06:22 +01:00
parent a16a6d2b54
commit 5f2058a6a0
2 changed files with 10 additions and 1 deletions

View file

@ -122,6 +122,15 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
if (!room) return;
const roomInfo = this.roomMap.get(room.roomId);
roomInfo.widgets = [];
// first clean out old widgets from the map which originate from this room
// otherwise we are out of sync with the rest of the app with stale widget events during removal
Array.from(this.widgetMap.values()).forEach(app => {
if (app.roomId === room.roomId) {
this.widgetMap.delete(app.id);
}
});
this.generateApps(room).forEach(app => {
this.widgetMap.set(app.id, app);
roomInfo.widgets.push(app);