This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +17
-6
lines changed Expand file tree Collapse file tree 4 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ import {throttle} from "lodash";
2121import ResizeObserver from 'resize-observer-polyfill' ;
2222
2323import dis from '../../../dispatcher/dispatcher' ;
24+ import MatrixClientContext from "../../../contexts/MatrixClientContext" ;
25+ import { MatrixClientPeg } from "../../../MatrixClientPeg" ;
2426
2527// Shamelessly ripped off Modal.js. There's probably a better way
2628// of doing reusable widgets like dialog boxes & menus where we go and
@@ -144,9 +146,11 @@ export default class PersistedElement extends React.Component {
144146 }
145147
146148 renderApp ( ) {
147- const content = < div ref = { this . collectChild } style = { this . props . style } >
148- { this . props . children }
149- </ div > ;
149+ const content = < MatrixClientContext . Provider value = { MatrixClientPeg . get ( ) } >
150+ < div ref = { this . collectChild } style = { this . props . style } >
151+ { this . props . children }
152+ </ div >
153+ </ MatrixClientContext . Provider > ;
150154
151155 ReactDOM . render ( content , getOrCreateContainer ( 'mx_persistedElement_' + this . props . persistKey ) ) ;
152156 }
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ import {SetRightPanelPhasePayload} from "../../../dispatcher/payloads/SetRightPa
3131import Modal from "../../../Modal" ;
3232import ShareDialog from '../dialogs/ShareDialog' ;
3333import { useEventEmitter } from "../../../hooks/useEventEmitter" ;
34- import WidgetEchoStore from "../../../stores/WidgetEchoStore" ;
3534import WidgetUtils from "../../../utils/WidgetUtils" ;
3635import { IntegrationManagers } from "../../../integrations/IntegrationManagers" ;
3736import SettingsStore from "../../../settings/SettingsStore" ;
@@ -77,7 +76,6 @@ export const useWidgets = (room: Room) => {
7776 } , [ room ] ) ;
7877
7978 useEffect ( updateApps , [ room ] ) ;
80- useEventEmitter ( WidgetEchoStore , "update" , updateApps ) ;
8179 useEventEmitter ( WidgetStore . instance , room . roomId , updateApps ) ;
8280
8381 return apps ;
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments