From 7524c15ec52876de573216838d1f8f69c0d24f10 Mon Sep 17 00:00:00 2001 From: Timo K Date: Mon, 22 Nov 2021 14:48:38 +0100 Subject: [PATCH] check on roomId instead of room --- src/components/views/voip/CallPreview.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/views/voip/CallPreview.tsx b/src/components/views/voip/CallPreview.tsx index a8f5f35f3b3f..7dff1db91bec 100644 --- a/src/components/views/voip/CallPreview.tsx +++ b/src/components/views/voip/CallPreview.tsx @@ -118,8 +118,8 @@ export default class CallPreview extends React.Component { this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate); this.dispatcherRef = dis.register(this.onAction); MatrixClientPeg.get().on(CallEvent.RemoteHoldUnhold, this.onCallRemoteHold); - const room = MatrixClientPeg.get().getRoom(this.state.roomId); - if (room) { + if (this.state.roomId) { + const room = MatrixClientPeg.get().getRoom(this.state.roomId); WidgetLayoutStore.instance.on(WidgetLayoutStore.emissionForRoom(room), this.updateCalls); } } @@ -142,12 +142,14 @@ export default class CallPreview extends React.Component { if (newRoomId === oldRoomId) return; // The WidgetLayoutStore observer always tracks the currently viewed Room, // so we don't end up with multiple observers and know what observer to remove on unmount - const newRoom = MatrixClientPeg.get().getRoom(newRoomId); - const oldRoom = MatrixClientPeg.get().getRoom(oldRoomId); - if (oldRoom) { + if (oldRoomId) { + const oldRoom = MatrixClientPeg.get().getRoom(oldRoomId); WidgetLayoutStore.instance.off(WidgetLayoutStore.emissionForRoom(oldRoom), this.updateCalls); } - WidgetLayoutStore.instance.on(WidgetLayoutStore.emissionForRoom(newRoom), this.updateCalls); + if (newRoomId) { + const newRoom = MatrixClientPeg.get().getRoom(newRoomId); + WidgetLayoutStore.instance.on(WidgetLayoutStore.emissionForRoom(newRoom), this.updateCalls); + } const [primaryCall, secondaryCalls] = getPrimarySecondaryCallsForPip(newRoomId); this.setState({