Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Destroy non-persistent widgets when switching room #2098

Merged
merged 2 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/views/elements/AppTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ 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)) {
ActiveWidgetStore.destroyPersistentWidget();
const PersistedElement = sdk.getComponent("elements.PersistedElement");
PersistedElement.destroyElement(this._persistKey);
}
}

Expand Down Expand Up @@ -437,6 +439,8 @@ export default class AppTile extends React.Component {

// Force the widget to be non-persistent
ActiveWidgetStore.destroyPersistentWidget();
const PersistedElement = sdk.getComponent("elements.PersistedElement");
PersistedElement.destroyElement(this._persistKey);
}

formatAppTileName() {
Expand Down
3 changes: 0 additions & 3 deletions src/stores/ActiveWidgetStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
import EventEmitter from 'events';

import MatrixClientPeg from '../MatrixClientPeg';
import sdk from '../index';

/**
* Stores information about the widgets active in the app right now:
Expand Down Expand Up @@ -75,8 +74,6 @@ class ActiveWidgetStore extends EventEmitter {
destroyPersistentWidget() {
const toDeleteId = this._persistentWidgetId;

const PersistedElement = sdk.getComponent("elements.PersistedElement");
PersistedElement.destroyElement('widget_' + toDeleteId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this didn't work? Seemed like a better place to do it...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'cos it was trying to destroy the one current persistent widget, but in the case of a jitsi widget which got mounted because you were in its room but never became persistent, it wouldn't destroy anything. The subtle difference is tearing down the current persistent widget vs tearing down the widget in the current view which has been mounted in a persisted element.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it 👍

this.setWidgetPersistence(toDeleteId, false);
this.delWidgetMessaging(toDeleteId);
this.delWidgetCapabilities(toDeleteId);
Expand Down