mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 09:46:09 +03:00
Move destroyPersistentWidget to store
This commit is contained in:
parent
acc767a479
commit
7044410a13
3 changed files with 15 additions and 18 deletions
|
@ -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 it's not remaining on screen, get rid of the PersistedElement container
|
||||||
if (!ActiveWidgetStore.getWidgetPersistence(this.props.id)) {
|
if (!ActiveWidgetStore.getWidgetPersistence(this.props.id)) {
|
||||||
// FIXME: ActiveWidgetStore should probably worry about this?
|
ActiveWidgetStore.destroyPersistentWidget();
|
||||||
this._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
|
* 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
|
||||||
|
@ -445,8 +436,7 @@ export default class AppTile extends React.Component {
|
||||||
this.setState({hasPermissionToLoad: false});
|
this.setState({hasPermissionToLoad: false});
|
||||||
|
|
||||||
// Force the widget to be non-persistent
|
// Force the widget to be non-persistent
|
||||||
ActiveWidgetStore.setWidgetPersistence(this.props.id, false);
|
ActiveWidgetStore.destroyPersistentWidget();
|
||||||
this._destroyPersistentWidget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
formatAppTileName() {
|
formatAppTileName() {
|
||||||
|
|
|
@ -66,15 +66,21 @@ class ActiveWidgetStore extends EventEmitter {
|
||||||
if (ev.getType() !== 'im.vector.modular.widgets') return;
|
if (ev.getType() !== 'im.vector.modular.widgets') return;
|
||||||
|
|
||||||
if (ev.getStateKey() === this._persistentWidgetId) {
|
if (ev.getStateKey() === this._persistentWidgetId) {
|
||||||
const PersistedElement = sdk.getComponent("elements.PersistedElement");
|
this.destroyPersistentWidget();
|
||||||
PersistedElement.destroyElement('widget_' + ev.getStateKey());
|
|
||||||
this.setWidgetPersistence(ev.getStateKey(), false);
|
|
||||||
this.delWidgetMessaging(ev.getStateKey());
|
|
||||||
this.delWidgetCapabilities(ev.getStateKey());
|
|
||||||
this.delRoomId(ev.getStateKey());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destroyPersistentWidget() {
|
||||||
|
const toDeleteId = this._persistentWidgetId;
|
||||||
|
|
||||||
|
const PersistedElement = sdk.getComponent("elements.PersistedElement");
|
||||||
|
PersistedElement.destroyElement('widget_' + toDeleteId);
|
||||||
|
this.setWidgetPersistence(toDeleteId, false);
|
||||||
|
this.delWidgetMessaging(toDeleteId);
|
||||||
|
this.delWidgetCapabilities(toDeleteId);
|
||||||
|
this.delRoomId(toDeleteId);
|
||||||
|
}
|
||||||
|
|
||||||
setWidgetPersistence(widgetId, val) {
|
setWidgetPersistence(widgetId, val) {
|
||||||
if (this._persistentWidgetId === widgetId && !val) {
|
if (this._persistentWidgetId === widgetId && !val) {
|
||||||
this._persistentWidgetId = null;
|
this._persistentWidgetId = null;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2017 Vector Creations Ltd
|
Copyright 2017 Vector Creations Ltd
|
||||||
|
Copyright 2018 New Vector Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|
Loading…
Reference in a new issue