Move destroyPersistentWidget to store

This commit is contained in:
David Baker 2018-07-24 16:50:34 +01:00
parent acc767a479
commit 7044410a13
3 changed files with 15 additions and 18 deletions

View file

@ -160,19 +160,10 @@ export default class AppTile extends React.Component {
// if it's not remaining on screen, get rid of the PersistedElement container
if (!ActiveWidgetStore.getWidgetPersistence(this.props.id)) {
// FIXME: ActiveWidgetStore should probably worry about this?
this._destroyPersistentWidget();
ActiveWidgetStore.destroyPersistentWidget();
}
}
_destroyPersistentWidget() {
const PersistedElement = sdk.getComponent("elements.PersistedElement");
PersistedElement.destroyElement(this._persistKey);
ActiveWidgetStore.delWidgetMessaging(this.props.id);
ActiveWidgetStore.delWidgetCapabilities(this.props.id);
ActiveWidgetStore.delRoomId(this.props.id);
}
/**
* Adds a scalar token to the widget URL, if required
* Component initialisation is only complete when this function has resolved
@ -445,8 +436,7 @@ export default class AppTile extends React.Component {
this.setState({hasPermissionToLoad: false});
// Force the widget to be non-persistent
ActiveWidgetStore.setWidgetPersistence(this.props.id, false);
this._destroyPersistentWidget();
ActiveWidgetStore.destroyPersistentWidget();
}
formatAppTileName() {