From 10930b84046c4cf15d6ab46fdf31e9476e248ebd Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 10 Dec 2020 20:57:20 -0700 Subject: [PATCH] Fix being unable to pin widgets Turns out that we were obliterating the entire store of widgets each time we loaded a widget, which is less than helpful. This commit fixes that. This commit also improves the cleanup of the pinned event object to remove unpinned widgets, reducing accumulation over time. Fixes https://github.com/vector-im/element-web/issues/15948 --- src/stores/WidgetStore.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stores/WidgetStore.ts b/src/stores/WidgetStore.ts index f1b5ea9be0..c9cf0a1c70 100644 --- a/src/stores/WidgetStore.ts +++ b/src/stores/WidgetStore.ts @@ -134,6 +134,7 @@ export default class WidgetStore extends AsyncStoreWithClient { // 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) return; // skip - wrong room this.widgetMap.delete(widgetUid(app)); }); @@ -233,7 +234,7 @@ export default class WidgetStore extends AsyncStoreWithClient { // Clean up the pinned record Object.keys(roomInfo).forEach(wId => { - if (!roomInfo.widgets.some(w => w.id === wId)) { + if (!roomInfo.widgets.some(w => w.id === wId) || !roomInfo.pinned[wId]) { delete roomInfo.pinned[wId]; } });