diff --git a/src/CallHandler.js b/src/CallHandler.js index abbd407e7f..7529171aa2 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -416,7 +416,7 @@ function _startCallApp(roomId, type) { const currentRoomWidgets = WidgetUtils.getRoomWidgets(room); - if (WidgetEchoStore.roomHasPendingWidgetsOfType(room, currentRoomWidgets, 'jitsi')) { + if (WidgetEchoStore.roomHasPendingWidgetsOfType(roomId, currentRoomWidgets, 'jitsi')) { const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); Modal.createTrackedDialog('Already have pending Jitsi Widget', '', ErrorDialog, { diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 5c97b5c29a..1850806520 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -328,9 +328,9 @@ module.exports = React.createClass({ return false; } - const widgets = WidgetEchoStore.getEchoedRoomWidgets(room, WidgetUtils.getRoomWidgets(room)); + const widgets = WidgetEchoStore.getEchoedRoomWidgets(room.roomId, WidgetUtils.getRoomWidgets(room)); - return widgets.length > 0 || WidgetEchoStore.roomHasPendingWidgets(room, WidgetUtils.getRoomWidgets(room)); + return widgets.length > 0 || WidgetEchoStore.roomHasPendingWidgets(room.roomId, WidgetUtils.getRoomWidgets(room)); }, componentDidMount: function() { diff --git a/src/components/views/rooms/AppsDrawer.js b/src/components/views/rooms/AppsDrawer.js index 64aa8fadc8..cdaa2d2b1a 100644 --- a/src/components/views/rooms/AppsDrawer.js +++ b/src/components/views/rooms/AppsDrawer.js @@ -167,7 +167,7 @@ module.exports = React.createClass({ _getApps: function() { const widgets = WidgetEchoStore.getEchoedRoomWidgets( - this.props.room, WidgetUtils.getRoomWidgets(this.props.room), + this.props.room.roomId, WidgetUtils.getRoomWidgets(this.props.room), ); return widgets.map((ev) => { return this._initAppConfig(ev.getStateKey(), ev.getContent(), ev.sender); @@ -260,7 +260,7 @@ module.exports = React.createClass({ let spinner; if ( apps.length === 0 && WidgetEchoStore.roomHasPendingWidgets( - this.props.room, + this.props.room.roomId, WidgetUtils.getRoomWidgets(this.props.room), ) ) { diff --git a/src/stores/WidgetEchoStore.js b/src/stores/WidgetEchoStore.js index f117b37e95..f50d0fd962 100644 --- a/src/stores/WidgetEchoStore.js +++ b/src/stores/WidgetEchoStore.js @@ -38,14 +38,14 @@ class WidgetEchoStore extends EventEmitter { * and we don't really need the actual widget events anyway since we just want to * show a spinner / prevent widgets being added twice. * - * @param {Room} room The room object to get widgets for + * @param {Room} roomId The ID of the room to get widgets for * @param {MatrixEvent[]} currentRoomWidgets Current widgets for the room * @returns {MatrixEvent[]} List of widgets in the room, minus any pending removal */ - getEchoedRoomWidgets(room, currentRoomWidgets) { + getEchoedRoomWidgets(roomId, currentRoomWidgets) { const echoedWidgets = []; - const roomEchoState = Object.assign({}, this._roomWidgetEcho[room.roomId]); + const roomEchoState = Object.assign({}, this._roomWidgetEcho[roomId]); for (const w of currentRoomWidgets) { const widgetId = w.getStateKey(); @@ -70,8 +70,8 @@ class WidgetEchoStore extends EventEmitter { return echoedWidgets; } - roomHasPendingWidgetsOfType(room, currentRoomWidgets, type) { - const roomEchoState = Object.assign({}, this._roomWidgetEcho[room.roomId]); + roomHasPendingWidgetsOfType(roomId, currentRoomWidgets, type) { + const roomEchoState = Object.assign({}, this._roomWidgetEcho[roomId]); if (roomEchoState === undefined) return false; for (const w of currentRoomWidgets) { @@ -88,20 +88,20 @@ class WidgetEchoStore extends EventEmitter { } } - roomHasPendingWidgets(room, currentRoomWidgets) { - return this.roomHasPendingWidgetsOfType(room, currentRoomWidgets); + roomHasPendingWidgets(roomId, currentRoomWidgets) { + return this.roomHasPendingWidgetsOfType(roomId, currentRoomWidgets); } - setRoomWidgetEcho(room, widgetId, state) { - if (this._roomWidgetEcho[room.roomId] === undefined) this._roomWidgetEcho[room.roomId] = {}; + setRoomWidgetEcho(roomId, widgetId, state) { + if (this._roomWidgetEcho[roomId] === undefined) this._roomWidgetEcho[roomId] = {}; - this._roomWidgetEcho[room.roomId][widgetId] = state; + this._roomWidgetEcho[roomId][widgetId] = state; this.emit('updateRoomWidgetEcho'); } - removeRoomWidgetEcho(room, widgetId) { - delete this._roomWidgetEcho[room.roomId][widgetId]; - if (this._roomWidgetEcho[room.roomId] === {}) delete this._roomWidgetEcho[room.roomId]; + removeRoomWidgetEcho(roomId, widgetId) { + delete this._roomWidgetEcho[roomId][widgetId]; + if (this._roomWidgetEcho[roomId] === {}) delete this._roomWidgetEcho[roomId]; this.emit('updateRoomWidgetEcho'); } } diff --git a/src/utils/WidgetUtils.js b/src/utils/WidgetUtils.js index 4effa21fd6..7bd50d063b 100644 --- a/src/utils/WidgetUtils.js +++ b/src/utils/WidgetUtils.js @@ -255,7 +255,7 @@ export default class WidgetUtils { } const room = MatrixClientPeg.get().getRoom(roomId); - WidgetEchoStore.setRoomWidgetEcho(room, widgetId, content); + WidgetEchoStore.setRoomWidgetEcho(roomId, widgetId, content); const client = MatrixClientPeg.get(); // TODO - Room widgets need to be moved to 'm.widget' state events @@ -263,7 +263,7 @@ export default class WidgetUtils { return client.sendStateEvent(roomId, "im.vector.modular.widgets", content, widgetId).then(() => { return WidgetUtils.waitForRoomWidget(widgetId, roomId, addingWidget); }).finally(() => { - WidgetEchoStore.removeRoomWidgetEcho(room, widgetId); + WidgetEchoStore.removeRoomWidgetEcho(roomId, widgetId); }); }