@@ -118,7 +118,7 @@ export default class CallPreview extends React.Component<IProps, IState> {
118
118
this . roomStoreToken = RoomViewStore . addListener ( this . onRoomViewStoreUpdate ) ;
119
119
this . dispatcherRef = dis . register ( this . onAction ) ;
120
120
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 ) ;
122
122
if ( room ) {
123
123
WidgetLayoutStore . instance . on ( WidgetLayoutStore . emissionForRoom ( room ) , this . updateCalls ) ;
124
124
}
@@ -142,12 +142,14 @@ export default class CallPreview extends React.Component<IProps, IState> {
142
142
if ( newRoomId === oldRoomId ) return ;
143
143
// The WidgetLayoutStore observer always tracks the currently viewed Room,
144
144
// 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 ) ;
147
146
if ( oldRoom ) {
148
147
WidgetLayoutStore . instance . off ( WidgetLayoutStore . emissionForRoom ( oldRoom ) , this . updateCalls ) ;
149
148
}
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
+ }
151
153
152
154
const [ primaryCall , secondaryCalls ] = getPrimarySecondaryCallsForPip ( newRoomId ) ;
153
155
this . setState ( {
0 commit comments