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

Only Destroy the expected persistent widget, not *ANY* #3338

Merged
merged 1 commit into from
Aug 28, 2019
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
7 changes: 3 additions & 4 deletions src/components/views/elements/AppTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ export default class AppTile extends React.Component {
// Widget action listeners
dis.unregister(this.dispatcherRef);

const canPersist = this.props.whitelistCapabilities.includes('m.always_on_screen');
// if it's not remaining on screen, get rid of the PersistedElement container
if (canPersist && !ActiveWidgetStore.getWidgetPersistence(this.props.id)) {
ActiveWidgetStore.destroyPersistentWidget();
if (!ActiveWidgetStore.getWidgetPersistence(this.props.id)) {
ActiveWidgetStore.destroyPersistentWidget(this.props.id);
const PersistedElement = sdk.getComponent("elements.PersistedElement");
PersistedElement.destroyElement(this._persistKey);
}
Expand Down Expand Up @@ -429,7 +428,7 @@ export default class AppTile extends React.Component {
this.setState({hasPermissionToLoad: false});

// Force the widget to be non-persistent
ActiveWidgetStore.destroyPersistentWidget();
ActiveWidgetStore.destroyPersistentWidget(this.props.id);
const PersistedElement = sdk.getComponent("elements.PersistedElement");
PersistedElement.destroyElement(this._persistKey);
}
Expand Down
5 changes: 3 additions & 2 deletions src/stores/ActiveWidgetStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ class ActiveWidgetStore extends EventEmitter {
if (ev.getType() !== 'im.vector.modular.widgets') return;

if (ev.getStateKey() === this._persistentWidgetId) {
this.destroyPersistentWidget();
this.destroyPersistentWidget(this._persistentWidgetId);
}
}

destroyPersistentWidget() {
destroyPersistentWidget(id) {
if (id !== this._persistentWidgetId) return;
const toDeleteId = this._persistentWidgetId;

this.setWidgetPersistence(toDeleteId, false);
Expand Down