diff --git a/src/components/views/rooms/Stickerpicker.js b/src/components/views/rooms/Stickerpicker.js index 9d8912954c..d9b23b0734 100644 --- a/src/components/views/rooms/Stickerpicker.js +++ b/src/components/views/rooms/Stickerpicker.js @@ -130,8 +130,13 @@ export default class Stickerpicker extends React.Component { _updateWidget() { const stickerpickerWidget = WidgetUtils.getStickerpickerWidgets()[0]; + if (!stickerpickerWidget) { + ActiveWidgetStore.delStickerPickerWidget(); + this.setState({stickerpickerWidget: null, widgetId: null}); + return; + } - const currentWidget = this.state.stickerpickerWidget; + const currentWidget = ActiveWidgetStore.getStickerPickerWidget(); let currentUrl = null; if (currentWidget && currentWidget.content && currentWidget.content.url) { currentUrl = currentWidget.content.url; @@ -147,6 +152,7 @@ export default class Stickerpicker extends React.Component { PersistedElement.destroyElement(PERSISTED_ELEMENT_KEY); } + ActiveWidgetStore.setStickerPickerWidget(stickerpickerWidget); this.setState({ stickerpickerWidget, widgetId: stickerpickerWidget ? stickerpickerWidget.id : null, diff --git a/src/stores/ActiveWidgetStore.js b/src/stores/ActiveWidgetStore.js index 89fa6e6936..1211195203 100644 --- a/src/stores/ActiveWidgetStore.js +++ b/src/stores/ActiveWidgetStore.js @@ -23,6 +23,7 @@ import MatrixClientPeg from '../MatrixClientPeg'; * * What widget is set to remain always-on-screen, if any * Only one widget may be 'always on screen' at any one time. * * Negotiated capabilities for active apps + * * Which stickerpicker the app is using, if any */ class ActiveWidgetStore extends EventEmitter { constructor() { @@ -41,6 +42,9 @@ class ActiveWidgetStore extends EventEmitter { // What room ID each widget is associated with (if it's a room widget) this._roomIdByWidgetId = {}; + // The sticker picker widget definition the app is currently using, if any + this._stickerPickerWidget = null; + this.onRoomStateEvents = this.onRoomStateEvents.bind(this); this.dispatcherRef = null; @@ -145,6 +149,18 @@ class ActiveWidgetStore extends EventEmitter { delete this._roomIdByWidgetId[widgetId]; this.emit('update'); } + + getStickerPickerWidget() { + return this._stickerPickerWidget; + } + + setStickerPickerWidget(widget) { + this._stickerPickerWidget = widget; + } + + delStickerPickerWidget() { + this._stickerPickerWidget = null; + } } if (global.singletonActiveWidgetStore === undefined) {