Cleanup
This commit is contained in:
parent
f8d7ab10fa
commit
1293c53c4b
1 changed files with 21 additions and 18 deletions
|
@ -160,10 +160,30 @@ export default class AppTile extends React.Component {
|
||||||
// postMessaging API
|
// postMessaging API
|
||||||
window.addEventListener('message', this._onMessage, false);
|
window.addEventListener('message', this._onMessage, false);
|
||||||
|
|
||||||
// General event handler
|
// Widget action listeners
|
||||||
this.dispatcherRef = dis.register(this._onWidgetAction);
|
this.dispatcherRef = dis.register(this._onWidgetAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
// Widget action listeners
|
||||||
|
console.warn('Removing widget event listener', this.dispatcherRef);
|
||||||
|
dis.unregister(this.dispatcherRef);
|
||||||
|
|
||||||
|
// 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.');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to stop listening for widgetMessaging events', e.message);
|
||||||
|
}
|
||||||
|
// Jitsi listener
|
||||||
|
window.removeEventListener('message', this._onMessage);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a scalar token to the widget URL, if required
|
* Adds a scalar token to the widget URL, if required
|
||||||
* Component initialisation is only complete when this function has resolved
|
* Component initialisation is only complete when this function has resolved
|
||||||
|
@ -216,23 +236,6 @@ export default class AppTile extends React.Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
// Widget action listeners
|
|
||||||
dis.unregister(this.dispatcherRef);
|
|
||||||
|
|
||||||
// Widget postMessage listeners
|
|
||||||
try {
|
|
||||||
if (this.widgetMessaging) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
// Jitsi listener
|
|
||||||
window.removeEventListener('message', this._onMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if (nextProps.url !== this.props.url) {
|
if (nextProps.url !== this.props.url) {
|
||||||
this._getNewState(nextProps);
|
this._getNewState(nextProps);
|
||||||
|
|
Loading…
Reference in a new issue