@@ -90,15 +90,15 @@ export default class RightPanelStore extends ReadyWatchingStore {
9090 * during room changes.
9191 */
9292 public get isOpen ( ) : boolean {
93- return this . byRoom [ this . viewedRoomId ] ?. isOpen ?? false ;
93+ return this . byRoom [ this . viewedRoomId ?? "" ] ?. isOpen ?? false ;
9494 }
9595
9696 public isOpenForRoom ( roomId : string ) : boolean {
9797 return this . byRoom [ roomId ] ?. isOpen ?? false ;
9898 }
9999
100100 public get roomPhaseHistory ( ) : Array < IRightPanelCard > {
101- return this . byRoom [ this . viewedRoomId ] ?. history ?? [ ] ;
101+ return this . byRoom [ this . viewedRoomId ?? "" ] ?. history ?? [ ] ;
102102 }
103103
104104 /**
@@ -133,7 +133,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
133133
134134 // Setters
135135 public setCard ( card : IRightPanelCard , allowClose = true , roomId ?: string ) : void {
136- const rId = roomId ?? this . viewedRoomId ;
136+ const rId = roomId ?? this . viewedRoomId ?? "" ;
137137 // This function behaves as following:
138138 // Update state: if the same phase is send but with a state
139139 // Set right panel and erase history: if a "different to the current" phase is send (with or without a state)
@@ -163,7 +163,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
163163
164164 public setCards ( cards : IRightPanelCard [ ] , allowClose = true , roomId : string | null = null ) : void {
165165 // This function sets the history of the right panel and shows the right panel if not already visible.
166- const rId = roomId ?? this . viewedRoomId ;
166+ const rId = roomId ?? this . viewedRoomId ?? "" ;
167167 const history = cards . map ( ( c ) => ( { phase : c . phase , state : c . state ?? { } } ) ) ;
168168 this . byRoom [ rId ] = { history, isOpen : true } ;
169169 this . show ( rId ) ;
@@ -172,7 +172,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
172172
173173 // Appends a card to the history and shows the right panel if not already visible
174174 public pushCard ( card : IRightPanelCard , allowClose = true , roomId : string | null = null ) : void {
175- const rId = roomId ?? this . viewedRoomId ;
175+ const rId = roomId ?? this . viewedRoomId ?? "" ;
176176 const redirect = this . getVerificationRedirect ( card ) ;
177177 const targetPhase = redirect ?. phase ?? card . phase ;
178178 const pState = redirect ?. state ?? card . state ?? { } ;
@@ -198,7 +198,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
198198 }
199199
200200 public popCard ( roomId : string | null = null ) : IRightPanelCard | undefined {
201- const rId = roomId ?? this . viewedRoomId ;
201+ const rId = roomId ?? this . viewedRoomId ?? "" ;
202202 if ( ! this . byRoom [ rId ] ) return ;
203203
204204 const removedCard = this . byRoom [ rId ] . history . pop ( ) ;
@@ -207,21 +207,21 @@ export default class RightPanelStore extends ReadyWatchingStore {
207207 }
208208
209209 public togglePanel ( roomId : string | null ) : void {
210- const rId = roomId ?? this . viewedRoomId ;
210+ const rId = roomId ?? this . viewedRoomId ?? "" ;
211211 if ( ! this . byRoom [ rId ] ) return ;
212212
213213 this . byRoom [ rId ] . isOpen = ! this . byRoom [ rId ] . isOpen ;
214214 this . emitAndUpdateSettings ( ) ;
215215 }
216216
217217 public show ( roomId : string | null ) : void {
218- if ( ! this . isOpenForRoom ( roomId ?? this . viewedRoomId ) ) {
218+ if ( ! this . isOpenForRoom ( roomId ?? this . viewedRoomId ?? "" ) ) {
219219 this . togglePanel ( roomId ) ;
220220 }
221221 }
222222
223223 public hide ( roomId : string | null ) : void {
224- if ( this . isOpenForRoom ( roomId ?? this . viewedRoomId ) ) {
224+ if ( this . isOpenForRoom ( roomId ?? this . viewedRoomId ?? "" ) ) {
225225 this . togglePanel ( roomId ) ;
226226 }
227227 }
@@ -360,7 +360,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
360360 // when we're switching to a room, clear out any stale MemberInfo cards
361361 // in order to fix https://github.com/vector-im/element-web/issues/21487
362362 if ( this . currentCard ?. phase !== RightPanelPhases . EncryptionPanel ) {
363- const panel = this . byRoom [ this . viewedRoomId ] ;
363+ const panel = this . byRoom [ this . viewedRoomId ?? "" ] ;
364364 if ( panel ?. history ) {
365365 panel . history = panel . history . filter (
366366 ( card : IRightPanelCard ) =>
@@ -380,13 +380,16 @@ export default class RightPanelStore extends ReadyWatchingStore {
380380 // If the right panel stays open mode is used, and the panel was either
381381 // closed or never shown for that room, then force it open and display
382382 // the room member list.
383- if ( SettingsStore . getValue ( "feature_right_panel_default_open" ) && ! this . byRoom [ this . viewedRoomId ] ?. isOpen ) {
383+ if (
384+ SettingsStore . getValue ( "feature_right_panel_default_open" ) &&
385+ ! this . byRoom [ this . viewedRoomId ?? "" ] ?. isOpen
386+ ) {
384387 const history = [ { phase : RightPanelPhases . RoomMemberList } ] ;
385388 const room = this . viewedRoomId ? this . mxClient ?. getRoom ( this . viewedRoomId ) : undefined ;
386389 if ( ! room ?. isSpaceRoom ( ) ) {
387390 history . unshift ( { phase : RightPanelPhases . RoomSummary } ) ;
388391 }
389- this . byRoom [ this . viewedRoomId ] = {
392+ this . byRoom [ this . viewedRoomId ?? "" ] = {
390393 isOpen : true ,
391394 history,
392395 } ;
0 commit comments