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)); } 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; 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);