General cleanup of handling for WidgetMessaging instances
When setting, delete the old one. Because delete checks if it exists first, we can safely call this. The change in FromWidgetPostMessageApi is just something noticed while debugging.pull/21833/head
parent
a4f76670c4
commit
51750cf153
|
@ -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);
|
||||
}
|
||||
ActiveWidgetStore.delWidgetMessaging(this.props.id);
|
||||
this._setupWidgetMessaging();
|
||||
|
||||
ActiveWidgetStore.setRoomId(this.props.id, this.props.room.roomId);
|
||||
|
|
|
@ -116,6 +116,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