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 d8bd382
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/components/views/voip/CallPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ 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);
const room = MatrixClientPeg.get()?.getRoom(this.state.roomId);
if (room) {
WidgetLayoutStore.instance.on(WidgetLayoutStore.emissionForRoom(room), this.updateCalls);
}
Expand All @@ -142,12 +142,15 @@ 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);
const oldRoom = MatrixClientPeg.get()?.getRoom(oldRoomId);
if (oldRoom) {
WidgetLayoutStore.instance.off(WidgetLayoutStore.emissionForRoom(oldRoom), this.updateCalls);
}
WidgetLayoutStore.instance.on(WidgetLayoutStore.emissionForRoom(newRoom), this.updateCalls);
const newRoom = MatrixClientPeg.get()?.getRoom(newRoomId);
if (newRoom) {
WidgetLayoutStore.instance.on(WidgetLayoutStore.emissionForRoom(newRoom), this.updateCalls);
}
if (!newRoomId) return;

const [primaryCall, secondaryCalls] = getPrimarySecondaryCallsForPip(newRoomId);
this.setState({
Expand All @@ -170,6 +173,7 @@ export default class CallPreview extends React.Component<IProps, IState> {
};

private updateCalls = () => {
if (!this.state.roomId) return;
const [primaryCall, secondaryCalls] = getPrimarySecondaryCallsForPip(this.state.roomId);

this.setState({
Expand All @@ -179,6 +183,7 @@ export default class CallPreview extends React.Component<IProps, IState> {
};

private onCallRemoteHold = () => {
if (!this.state.roomId) return;
const [primaryCall, secondaryCalls] = getPrimarySecondaryCallsForPip(this.state.roomId);

this.setState({
Expand Down

0 comments on commit d8bd382

Please sign in to comment.