From 657dcaf9895a62629e57d0673b2dca3ec075c813 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 12 Aug 2021 18:36:57 +0100 Subject: [PATCH 1/2] Fix video call persisting when widget removed Fixes https://github.com/vector-im/element-web/issues/15703 Type: defect --- src/stores/WidgetStore.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/stores/WidgetStore.ts b/src/stores/WidgetStore.ts index 732428107f8..f1a0e165e8d 100644 --- a/src/stores/WidgetStore.ts +++ b/src/stores/WidgetStore.ts @@ -137,6 +137,26 @@ export default class WidgetStore extends AsyncStoreWithClient { if (edited && !this.roomMap.has(room.roomId)) { this.roomMap.set(room.roomId, roomInfo); } + + // If a persistent widget is active, check to see if it's just been removed. + // If it has, it needs to destroyed otherwise unmounting the node won't kill it + const persistentWidgetId = ActiveWidgetStore.getPersistentWidgetId(); + if (persistentWidgetId) { + if ( + ActiveWidgetStore.getRoomId(persistentWidgetId) === room.roomId && + !roomInfo.widgets.some(w => w.id === persistentWidgetId) + ) { + console.log(`Persistent widget ${persistentWidgetId} removed from room ${room.roomId}: destroying.`); + ActiveWidgetStore.destroyPersistentWidget(persistentWidgetId); + } + } + + /*if ( + oldWidgetIds.includes(ActiveWidgetStore.getPersistentWidgetId()) && + !roomInfo.widgets.map(w => w.id).includes(ActiveWidgetStore.getPersistentWidgetId())) { + ActiveWidgetStore.destroyPersistentWidget(ActiveWidgetStore.getPersistentWidgetId()); + }*/ + this.emit(room.roomId); } From 3528d87f30f686c5dfc84d902df55bbd482f7935 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 12 Aug 2021 18:39:11 +0100 Subject: [PATCH 2/2] Remove old version --- src/stores/WidgetStore.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/stores/WidgetStore.ts b/src/stores/WidgetStore.ts index f1a0e165e8d..e9820eee06b 100644 --- a/src/stores/WidgetStore.ts +++ b/src/stores/WidgetStore.ts @@ -151,12 +151,6 @@ export default class WidgetStore extends AsyncStoreWithClient { } } - /*if ( - oldWidgetIds.includes(ActiveWidgetStore.getPersistentWidgetId()) && - !roomInfo.widgets.map(w => w.id).includes(ActiveWidgetStore.getPersistentWidgetId())) { - ActiveWidgetStore.destroyPersistentWidget(ActiveWidgetStore.getPersistentWidgetId()); - }*/ - this.emit(room.roomId); }