@@ -118,8 +118,8 @@ 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 ) ;
122- if ( room ) {
121+ if ( this . state . roomId ) {
122+ const room = MatrixClientPeg . get ( ) . getRoom ( this . state . roomId ) ;
123123 WidgetLayoutStore . instance . on ( WidgetLayoutStore . emissionForRoom ( room ) , this . updateCalls ) ;
124124 }
125125 }
@@ -142,11 +142,11 @@ 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 ) ;
147- if ( oldRoom ) {
145+ if ( oldRoomId ) {
146+ const oldRoom = MatrixClientPeg . get ( ) . getRoom ( oldRoomId ) ;
148147 WidgetLayoutStore . instance . off ( WidgetLayoutStore . emissionForRoom ( oldRoom ) , this . updateCalls ) ;
149148 }
149+ const newRoom = MatrixClientPeg . get ( ) . getRoom ( newRoomId ) ;
150150 WidgetLayoutStore . instance . on ( WidgetLayoutStore . emissionForRoom ( newRoom ) , this . updateCalls ) ;
151151
152152 const [ primaryCall , secondaryCalls ] = getPrimarySecondaryCallsForPip ( newRoomId ) ;
0 commit comments