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

Commit d8bd382

Browse files
committed
check on roomId instead of room
1 parent 57e11d3 commit d8bd382

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/components/views/voip/CallPreview.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export default class CallPreview extends React.Component<IProps, IState> {
118118
this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate);
119119
this.dispatcherRef = dis.register(this.onAction);
120120
MatrixClientPeg.get().on(CallEvent.RemoteHoldUnhold, this.onCallRemoteHold);
121-
const room = MatrixClientPeg.get().getRoom(this.state.roomId);
121+
const room = MatrixClientPeg.get()?.getRoom(this.state.roomId);
122122
if (room) {
123123
WidgetLayoutStore.instance.on(WidgetLayoutStore.emissionForRoom(room), this.updateCalls);
124124
}
@@ -142,12 +142,15 @@ export default class CallPreview extends React.Component<IProps, IState> {
142142
if (newRoomId === oldRoomId) return;
143143
// The WidgetLayoutStore observer always tracks the currently viewed Room,
144144
// so we don't end up with multiple observers and know what observer to remove on unmount
145-
const newRoom = MatrixClientPeg.get().getRoom(newRoomId);
146-
const oldRoom = MatrixClientPeg.get().getRoom(oldRoomId);
145+
const oldRoom = MatrixClientPeg.get()?.getRoom(oldRoomId);
147146
if (oldRoom) {
148147
WidgetLayoutStore.instance.off(WidgetLayoutStore.emissionForRoom(oldRoom), this.updateCalls);
149148
}
150-
WidgetLayoutStore.instance.on(WidgetLayoutStore.emissionForRoom(newRoom), this.updateCalls);
149+
const newRoom = MatrixClientPeg.get()?.getRoom(newRoomId);
150+
if (newRoom) {
151+
WidgetLayoutStore.instance.on(WidgetLayoutStore.emissionForRoom(newRoom), this.updateCalls);
152+
}
153+
if (!newRoomId) return;
151154

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

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

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

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

184189
this.setState({

0 commit comments

Comments
 (0)