Fix duplicate message listeners

This commit is contained in:
Richard Lewis 2018-01-18 13:16:06 +00:00
parent 910623d287
commit 23bef68a8f
2 changed files with 14 additions and 10 deletions

View file

@ -171,12 +171,8 @@ export default class AppTile extends React.Component {
// Widget postMessage listeners
try {
if (this.widgetMessaging) {
this.widgetMessaging.stopListening();
this.widgetMessaging.removeEndpoint(this.props.id, this.props.url);
} else {
console.warn('WidgetMessaging not initialised. Not stopping.');
}
this.widgetMessaging.stopListening();
this.widgetMessaging.removeEndpoint(this.props.id, this.props.url);
} catch (e) {
console.error('Failed to stop listening for widgetMessaging events', e.message);
}