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.
This commit is contained in:
Travis Ralston 2019-04-01 19:50:05 -06:00
parent a4f76670c4
commit 51750cf153
3 changed files with 5 additions and 7 deletions

View file

@ -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;