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

Commit

Permalink
check on roomId instead of room
Browse files Browse the repository at this point in the history
  • Loading branch information
toger5 committed Nov 22, 2021
1 parent 57e11d3 commit 7524c15
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/views/voip/CallPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ export default class CallPreview extends React.Component<IProps, IState> {
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);
}
}
Expand All @@ -142,12 +142,14 @@ export default class CallPreview extends React.Component<IProps, IState> {
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({
Expand Down

0 comments on commit 7524c15

Please sign in to comment.