mirror of https://github.com/vector-im/riot-web
Merge pull request #2862 from matrix-org/travis/stickerpicker/remount
Don't re-init the stickerpicker unless something actually changespull/21833/head
commit
a61ab4eb4e
|
@ -116,10 +116,8 @@ export default class FromWidgetPostMessageApi {
|
|||
const origin = u.protocol + '//' + u.host;
|
||||
if (this.widgetMessagingEndpoints && this.widgetMessagingEndpoints.length > 0) {
|
||||
const length = this.widgetMessagingEndpoints.length;
|
||||
this.widgetMessagingEndpoints = this.widgetMessagingEndpoints.
|
||||
filter(function(endpoint) {
|
||||
return (endpoint.widgetId != widgetId || endpoint.endpointUrl != origin);
|
||||
});
|
||||
this.widgetMessagingEndpoints = this.widgetMessagingEndpoints
|
||||
.filter((endpoint) => endpoint.widgetId !== widgetId || endpoint.endpointUrl !== origin);
|
||||
return (length > this.widgetMessagingEndpoints.length);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -339,9 +339,7 @@ export default class AppTile extends React.Component {
|
|||
// Destroy the old widget messaging before starting it back up again. Some widgets
|
||||
// have startup routines that run when they are loaded, so we just need to reinitialize
|
||||
// the messaging for them.
|
||||
if (ActiveWidgetStore.getWidgetMessaging(this.props.id)) {
|
||||
ActiveWidgetStore.delWidgetMessaging(this.props.id);
|
||||
}
|
||||
this._setupWidgetMessaging();
|
||||
|
||||
ActiveWidgetStore.setRoomId(this.props.id, this.props.room.roomId);
|
||||
|
|
|
@ -37,6 +37,8 @@ const STICKERPICKER_Z_INDEX = 3500;
|
|||
const PERSISTED_ELEMENT_KEY = "stickerPicker";
|
||||
|
||||
export default class Stickerpicker extends React.Component {
|
||||
static currentWidget;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this._onShowStickersClick = this._onShowStickersClick.bind(this);
|
||||
|
@ -130,8 +132,13 @@ export default class Stickerpicker extends React.Component {
|
|||
|
||||
_updateWidget() {
|
||||
const stickerpickerWidget = WidgetUtils.getStickerpickerWidgets()[0];
|
||||
if (!stickerpickerWidget) {
|
||||
Stickerpicker.currentWidget = null;
|
||||
this.setState({stickerpickerWidget: null, widgetId: null});
|
||||
return;
|
||||
}
|
||||
|
||||
const currentWidget = this.state.stickerpickerWidget;
|
||||
const currentWidget = Stickerpicker.currentWidget;
|
||||
let currentUrl = null;
|
||||
if (currentWidget && currentWidget.content && currentWidget.content.url) {
|
||||
currentUrl = currentWidget.content.url;
|
||||
|
@ -147,6 +154,7 @@ export default class Stickerpicker extends React.Component {
|
|||
PersistedElement.destroyElement(PERSISTED_ELEMENT_KEY);
|
||||
}
|
||||
|
||||
Stickerpicker.currentWidget = stickerpickerWidget;
|
||||
this.setState({
|
||||
stickerpickerWidget,
|
||||
widgetId: stickerpickerWidget ? stickerpickerWidget.id : null,
|
||||
|
|
|
@ -112,6 +112,8 @@ class ActiveWidgetStore extends EventEmitter {
|
|||
}
|
||||
|
||||
setWidgetMessaging(widgetId, wm) {
|
||||
// Stop any existing widget messaging first
|
||||
this.delWidgetMessaging(widgetId);
|
||||
this._widgetMessagingByWidgetId[widgetId] = wm;
|
||||
this.emit('update');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue