From a2280aae64838e70873b6f4172874ad1a8ef4002 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 21 Oct 2020 16:05:20 +0100 Subject: [PATCH 1/3] Fix stickerpicker not having correct contexts Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/elements/PersistedElement.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/views/elements/PersistedElement.js b/src/components/views/elements/PersistedElement.js index fc0b9edddd..488af5c6a9 100644 --- a/src/components/views/elements/PersistedElement.js +++ b/src/components/views/elements/PersistedElement.js @@ -21,6 +21,8 @@ import {throttle} from "lodash"; import ResizeObserver from 'resize-observer-polyfill'; import dis from '../../../dispatcher/dispatcher'; +import MatrixClientContext from "../../../contexts/MatrixClientContext"; +import {MatrixClientPeg} from "../../../MatrixClientPeg"; // Shamelessly ripped off Modal.js. There's probably a better way // of doing reusable widgets like dialog boxes & menus where we go and @@ -144,9 +146,11 @@ export default class PersistedElement extends React.Component { } renderApp() { - const content =
- {this.props.children} -
; + const content = +
+ {this.props.children} +
+
; ReactDOM.render(content, getOrCreateContainer('mx_persistedElement_'+this.props.persistKey)); } From 951ad5d58174adf23eff00c3da21eeed55e0d5dd Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 21 Oct 2020 16:05:44 +0100 Subject: [PATCH 2/3] Remove redundant event listener Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/right_panel/RoomSummaryCard.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/views/right_panel/RoomSummaryCard.tsx b/src/components/views/right_panel/RoomSummaryCard.tsx index 77e76d1c25..621e85e1d4 100644 --- a/src/components/views/right_panel/RoomSummaryCard.tsx +++ b/src/components/views/right_panel/RoomSummaryCard.tsx @@ -31,7 +31,6 @@ import {SetRightPanelPhasePayload} from "../../../dispatcher/payloads/SetRightPa import Modal from "../../../Modal"; import ShareDialog from '../dialogs/ShareDialog'; import {useEventEmitter} from "../../../hooks/useEventEmitter"; -import WidgetEchoStore from "../../../stores/WidgetEchoStore"; import WidgetUtils from "../../../utils/WidgetUtils"; import {IntegrationManagers} from "../../../integrations/IntegrationManagers"; import SettingsStore from "../../../settings/SettingsStore"; @@ -77,7 +76,6 @@ export const useWidgets = (room: Room) => { }, [room]); useEffect(updateApps, [room]); - useEventEmitter(WidgetEchoStore, "update", updateApps); useEventEmitter(WidgetStore.instance, room.roomId, updateApps); return apps; From cf23417e6e43e65f9ed0b60f685c219dd59b5c32 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 21 Oct 2020 16:06:22 +0100 Subject: [PATCH 3/3] Fix WidgetStore wrongly hanging onto old Widget definitions during removal Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/stores/WidgetEchoStore.js | 2 +- src/stores/WidgetStore.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/stores/WidgetEchoStore.js b/src/stores/WidgetEchoStore.js index 7dd093d45e..3aef1beb3e 100644 --- a/src/stores/WidgetEchoStore.js +++ b/src/stores/WidgetEchoStore.js @@ -55,7 +55,7 @@ class WidgetEchoStore extends EventEmitter { const widgetId = w.getStateKey(); // If there's no echo, or the echo still has a widget present, show the *old* widget // we don't include widgets that have changed for the same reason we don't include new ones, - // ie. we'd need to fake matrix events to do so and therte's currently no need. + // ie. we'd need to fake matrix events to do so and there's currently no need. if (!roomEchoState[widgetId] || Object.keys(roomEchoState[widgetId]).length !== 0) { echoedWidgets.push(w); } diff --git a/src/stores/WidgetStore.ts b/src/stores/WidgetStore.ts index 1caea659ca..a8040f57de 100644 --- a/src/stores/WidgetStore.ts +++ b/src/stores/WidgetStore.ts @@ -122,6 +122,15 @@ export default class WidgetStore extends AsyncStoreWithClient { 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);