You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-20 16:22:28 +03:00
Merge pull request #2862 from matrix-org/travis/stickerpicker/remount
Don't re-init the stickerpicker unless something actually changes
This commit is contained in:
@@ -116,10 +116,8 @@ export default class FromWidgetPostMessageApi {
|
|||||||
const origin = u.protocol + '//' + u.host;
|
const origin = u.protocol + '//' + u.host;
|
||||||
if (this.widgetMessagingEndpoints && this.widgetMessagingEndpoints.length > 0) {
|
if (this.widgetMessagingEndpoints && this.widgetMessagingEndpoints.length > 0) {
|
||||||
const length = this.widgetMessagingEndpoints.length;
|
const length = this.widgetMessagingEndpoints.length;
|
||||||
this.widgetMessagingEndpoints = this.widgetMessagingEndpoints.
|
this.widgetMessagingEndpoints = this.widgetMessagingEndpoints
|
||||||
filter(function(endpoint) {
|
.filter((endpoint) => endpoint.widgetId !== widgetId || endpoint.endpointUrl !== origin);
|
||||||
return (endpoint.widgetId != widgetId || endpoint.endpointUrl != origin);
|
|
||||||
});
|
|
||||||
return (length > this.widgetMessagingEndpoints.length);
|
return (length > this.widgetMessagingEndpoints.length);
|
||||||
}
|
}
|
||||||
return false;
|
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
|
// 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
|
// have startup routines that run when they are loaded, so we just need to reinitialize
|
||||||
// the messaging for them.
|
// the messaging for them.
|
||||||
if (ActiveWidgetStore.getWidgetMessaging(this.props.id)) {
|
|
||||||
ActiveWidgetStore.delWidgetMessaging(this.props.id);
|
ActiveWidgetStore.delWidgetMessaging(this.props.id);
|
||||||
}
|
|
||||||
this._setupWidgetMessaging();
|
this._setupWidgetMessaging();
|
||||||
|
|
||||||
ActiveWidgetStore.setRoomId(this.props.id, this.props.room.roomId);
|
ActiveWidgetStore.setRoomId(this.props.id, this.props.room.roomId);
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ 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);
|
||||||
@@ -130,8 +132,13 @@ export default class Stickerpicker extends React.Component {
|
|||||||
|
|
||||||
_updateWidget() {
|
_updateWidget() {
|
||||||
const stickerpickerWidget = WidgetUtils.getStickerpickerWidgets()[0];
|
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;
|
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;
|
||||||
@@ -147,6 +154,7 @@ export default class Stickerpicker extends React.Component {
|
|||||||
PersistedElement.destroyElement(PERSISTED_ELEMENT_KEY);
|
PersistedElement.destroyElement(PERSISTED_ELEMENT_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Stickerpicker.currentWidget = stickerpickerWidget;
|
||||||
this.setState({
|
this.setState({
|
||||||
stickerpickerWidget,
|
stickerpickerWidget,
|
||||||
widgetId: stickerpickerWidget ? stickerpickerWidget.id : null,
|
widgetId: stickerpickerWidget ? stickerpickerWidget.id : null,
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ class ActiveWidgetStore extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setWidgetMessaging(widgetId, wm) {
|
setWidgetMessaging(widgetId, wm) {
|
||||||
|
// Stop any existing widget messaging first
|
||||||
|
this.delWidgetMessaging(widgetId);
|
||||||
this._widgetMessagingByWidgetId[widgetId] = wm;
|
this._widgetMessagingByWidgetId[widgetId] = wm;
|
||||||
this.emit('update');
|
this.emit('update');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user