Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 5f2058a

Browse files
committed
Fix WidgetStore wrongly hanging onto old Widget definitions during removal
Signed-off-by: Michael Telatynski <[email protected]>
1 parent a16a6d2 commit 5f2058a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/stores/WidgetEchoStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class WidgetEchoStore extends EventEmitter {
5555
const widgetId = w.getStateKey();
5656
// If there's no echo, or the echo still has a widget present, show the *old* widget
5757
// we don't include widgets that have changed for the same reason we don't include new ones,
58-
// ie. we'd need to fake matrix events to do so and therte's currently no need.
58+
// ie. we'd need to fake matrix events to do so and there's currently no need.
5959
if (!roomEchoState[widgetId] || Object.keys(roomEchoState[widgetId]).length !== 0) {
6060
echoedWidgets.push(w);
6161
}

src/stores/WidgetStore.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
122122
if (!room) return;
123123
const roomInfo = this.roomMap.get(room.roomId);
124124
roomInfo.widgets = [];
125+
126+
// first clean out old widgets from the map which originate from this room
127+
// otherwise we are out of sync with the rest of the app with stale widget events during removal
128+
Array.from(this.widgetMap.values()).forEach(app => {
129+
if (app.roomId === room.roomId) {
130+
this.widgetMap.delete(app.id);
131+
}
132+
});
133+
125134
this.generateApps(room).forEach(app => {
126135
this.widgetMap.set(app.id, app);
127136
roomInfo.widgets.push(app);

0 commit comments

Comments
 (0)