mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 02:05:45 +03:00
Use a static prop on Stickerpicker to track the current widget
This commit is contained in:
parent
ad777782b8
commit
10369170ed
2 changed files with 6 additions and 18 deletions
|
@ -37,6 +37,9 @@ const STICKERPICKER_Z_INDEX = 3500;
|
||||||
const PERSISTED_ELEMENT_KEY = "stickerPicker";
|
const PERSISTED_ELEMENT_KEY = "stickerPicker";
|
||||||
|
|
||||||
export default class Stickerpicker extends React.Component {
|
export default class Stickerpicker extends React.Component {
|
||||||
|
|
||||||
|
static currentWidget;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this._onShowStickersClick = this._onShowStickersClick.bind(this);
|
this._onShowStickersClick = this._onShowStickersClick.bind(this);
|
||||||
|
@ -131,12 +134,12 @@ export default class Stickerpicker extends React.Component {
|
||||||
_updateWidget() {
|
_updateWidget() {
|
||||||
const stickerpickerWidget = WidgetUtils.getStickerpickerWidgets()[0];
|
const stickerpickerWidget = WidgetUtils.getStickerpickerWidgets()[0];
|
||||||
if (!stickerpickerWidget) {
|
if (!stickerpickerWidget) {
|
||||||
ActiveWidgetStore.delStickerPickerWidget();
|
Stickerpicker.currentWidget = null;
|
||||||
this.setState({stickerpickerWidget: null, widgetId: null});
|
this.setState({stickerpickerWidget: null, widgetId: null});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentWidget = ActiveWidgetStore.getStickerPickerWidget();
|
const currentWidget = Stickerpicker.currentWidget;
|
||||||
let currentUrl = null;
|
let currentUrl = null;
|
||||||
if (currentWidget && currentWidget.content && currentWidget.content.url) {
|
if (currentWidget && currentWidget.content && currentWidget.content.url) {
|
||||||
currentUrl = currentWidget.content.url;
|
currentUrl = currentWidget.content.url;
|
||||||
|
@ -152,7 +155,7 @@ export default class Stickerpicker extends React.Component {
|
||||||
PersistedElement.destroyElement(PERSISTED_ELEMENT_KEY);
|
PersistedElement.destroyElement(PERSISTED_ELEMENT_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveWidgetStore.setStickerPickerWidget(stickerpickerWidget);
|
Stickerpicker.currentWidget = stickerpickerWidget;
|
||||||
this.setState({
|
this.setState({
|
||||||
stickerpickerWidget,
|
stickerpickerWidget,
|
||||||
widgetId: stickerpickerWidget ? stickerpickerWidget.id : null,
|
widgetId: stickerpickerWidget ? stickerpickerWidget.id : null,
|
||||||
|
|
|
@ -42,9 +42,6 @@ class ActiveWidgetStore extends EventEmitter {
|
||||||
// What room ID each widget is associated with (if it's a room widget)
|
// What room ID each widget is associated with (if it's a room widget)
|
||||||
this._roomIdByWidgetId = {};
|
this._roomIdByWidgetId = {};
|
||||||
|
|
||||||
// The sticker picker widget definition the app is currently using, if any
|
|
||||||
this._stickerPickerWidget = null;
|
|
||||||
|
|
||||||
this.onRoomStateEvents = this.onRoomStateEvents.bind(this);
|
this.onRoomStateEvents = this.onRoomStateEvents.bind(this);
|
||||||
|
|
||||||
this.dispatcherRef = null;
|
this.dispatcherRef = null;
|
||||||
|
@ -151,18 +148,6 @@ class ActiveWidgetStore extends EventEmitter {
|
||||||
delete this._roomIdByWidgetId[widgetId];
|
delete this._roomIdByWidgetId[widgetId];
|
||||||
this.emit('update');
|
this.emit('update');
|
||||||
}
|
}
|
||||||
|
|
||||||
getStickerPickerWidget() {
|
|
||||||
return this._stickerPickerWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
setStickerPickerWidget(widget) {
|
|
||||||
this._stickerPickerWidget = widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
delStickerPickerWidget() {
|
|
||||||
this._stickerPickerWidget = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global.singletonActiveWidgetStore === undefined) {
|
if (global.singletonActiveWidgetStore === undefined) {
|
||||||
|
|
Loading…
Reference in a new issue