Ensure widgets are destroyed cleanly when minimized

Fixes https://github.com/vector-im/element-web/issues/15444 (an artifact of joining a call then minimizing the widget)

Also fixes other issues relating to widgets not loading when being minimized/maximized.
pull/21833/head
Travis Ralston 2020-10-13 14:55:44 -06:00
parent 40038a6100
commit 294c35347c
3 changed files with 15 additions and 3 deletions

View File

@ -240,10 +240,14 @@ export default class AppTile extends React.Component {
this.iframe.src = 'about:blank'; this.iframe.src = 'about:blank';
} }
if (WidgetType.JITSI.matches(this.props.app.type)) {
dis.dispatch({action: 'hangup_conference'});
}
// Delete the widget from the persisted store for good measure. // Delete the widget from the persisted store for good measure.
PersistedElement.destroyElement(this._persistKey); PersistedElement.destroyElement(this._persistKey);
this._sgWidget.stop(); this._sgWidget.stop({forceDestroy: true});
} }
/* If user has permission to modify widgets, delete the widget, /* If user has permission to modify widgets, delete the widget,
@ -387,6 +391,9 @@ export default class AppTile extends React.Component {
if (this.props.show) { if (this.props.show) {
// if we were being shown, end the widget as we're about to be minimized. // if we were being shown, end the widget as we're about to be minimized.
this._endWidgetActions(); this._endWidgetActions();
} else {
// restart the widget actions
this._resetWidget(this.props);
} }
dis.dispatch({ dis.dispatch({
action: 'appsDrawer', action: 'appsDrawer',

View File

@ -58,6 +58,11 @@ export default class PersistentApp extends React.Component {
const persistentWidgetInRoomId = ActiveWidgetStore.getRoomId(this.state.persistentWidgetId); const persistentWidgetInRoomId = ActiveWidgetStore.getRoomId(this.state.persistentWidgetId);
if (this.state.roomId !== persistentWidgetInRoomId) { if (this.state.roomId !== persistentWidgetInRoomId) {
const persistentWidgetInRoom = MatrixClientPeg.get().getRoom(persistentWidgetInRoomId); const persistentWidgetInRoom = MatrixClientPeg.get().getRoom(persistentWidgetInRoomId);
// Sanity check the room - the widget may have been destroyed between render cycles, and
// thus no room is associated anymore.
if (!persistentWidgetInRoom) return null;
// get the widget data // get the widget data
const appEvent = WidgetUtils.getRoomWidgets(persistentWidgetInRoom).find((ev) => { const appEvent = WidgetUtils.getRoomWidgets(persistentWidgetInRoom).find((ev) => {
return ev.getStateKey() === ActiveWidgetStore.getPersistentWidgetId(); return ev.getStateKey() === ActiveWidgetStore.getPersistentWidgetId();

View File

@ -283,8 +283,8 @@ export class StopGapWidget extends EventEmitter {
} }
} }
public stop() { public stop(opts = {forceDestroy: false}) {
if (ActiveWidgetStore.getPersistentWidgetId() === this.mockWidget.id) { if (!opts?.forceDestroy && ActiveWidgetStore.getPersistentWidgetId() === this.mockWidget.id) {
console.log("Skipping destroy - persistent widget"); console.log("Skipping destroy - persistent widget");
return; return;
} }