@@ -44,26 +44,37 @@ import TimelineCard from "../views/right_panel/TimelineCard";
44
44
import { UPDATE_EVENT } from "../../stores/AsyncStore" ;
45
45
import { IRightPanelCard , IRightPanelCardState } from "../../stores/right-panel/RightPanelStoreIPanelState" ;
46
46
import { Action } from "../../dispatcher/actions" ;
47
+ import { XOR } from "../../@types/common" ;
47
48
48
- interface IProps {
49
- room ?: Room ; // if showing panels for a given room, this is set
49
+ interface BaseProps {
50
50
overwriteCard ?: IRightPanelCard ; // used to display a custom card and ignoring the RightPanelStore (used for UserView)
51
51
resizeNotifier : ResizeNotifier ;
52
- permalinkCreator ?: RoomPermalinkCreator ;
53
52
e2eStatus ?: E2EStatus ;
54
53
}
55
54
55
+ interface RoomlessProps extends BaseProps {
56
+ room ?: undefined ;
57
+ permalinkCreator ?: undefined ;
58
+ }
59
+
60
+ interface RoomProps extends BaseProps {
61
+ room : Room ;
62
+ permalinkCreator : RoomPermalinkCreator ;
63
+ }
64
+
65
+ type Props = XOR < RoomlessProps , RoomProps > ;
66
+
56
67
interface IState {
57
68
phase ?: RightPanelPhases ;
58
69
searchQuery : string ;
59
70
cardState ?: IRightPanelCardState ;
60
71
}
61
72
62
- export default class RightPanel extends React . Component < IProps , IState > {
73
+ export default class RightPanel extends React . Component < Props , IState > {
63
74
public static contextType = MatrixClientContext ;
64
75
public context ! : React . ContextType < typeof MatrixClientContext > ;
65
76
66
- public constructor ( props : IProps , context : React . ContextType < typeof MatrixClientContext > ) {
77
+ public constructor ( props : Props , context : React . ContextType < typeof MatrixClientContext > ) {
67
78
super ( props , context ) ;
68
79
69
80
this . state = {
@@ -89,7 +100,7 @@ export default class RightPanel extends React.Component<IProps, IState> {
89
100
RightPanelStore . instance . off ( UPDATE_EVENT , this . onRightPanelStoreUpdate ) ;
90
101
}
91
102
92
- public static getDerivedStateFromProps ( props : IProps ) : Partial < IState > {
103
+ public static getDerivedStateFromProps ( props : Props ) : Partial < IState > {
93
104
let currentCard : IRightPanelCard | undefined ;
94
105
if ( props . room ) {
95
106
currentCard = RightPanelStore . instance . currentCardForRoom ( props . room . roomId ) ;
@@ -169,32 +180,36 @@ export default class RightPanel extends React.Component<IProps, IState> {
169
180
}
170
181
break ;
171
182
case RightPanelPhases . SpaceMemberList :
172
- card = (
173
- < MemberList
174
- roomId = { cardState ?. spaceId ?? roomId }
175
- key = { cardState ?. spaceId ?? roomId }
176
- onClose = { this . onClose }
177
- searchQuery = { this . state . searchQuery }
178
- onSearchQueryChanged = { this . onSearchQueryChanged }
179
- />
180
- ) ;
183
+ if ( ! ! cardState ?. spaceId || ! ! roomId ) {
184
+ card = (
185
+ < MemberList
186
+ roomId = { cardState ?. spaceId ?? roomId ! }
187
+ key = { cardState ?. spaceId ?? roomId ! }
188
+ onClose = { this . onClose }
189
+ searchQuery = { this . state . searchQuery }
190
+ onSearchQueryChanged = { this . onSearchQueryChanged }
191
+ />
192
+ ) ;
193
+ }
181
194
break ;
182
195
183
196
case RightPanelPhases . RoomMemberInfo :
184
197
case RightPanelPhases . SpaceMemberInfo :
185
198
case RightPanelPhases . EncryptionPanel : {
186
- const roomMember = cardState ?. member instanceof RoomMember ? cardState . member : undefined ;
187
- card = (
188
- < UserInfo
189
- user = { cardState ?. member }
190
- room = { this . context . getRoom ( roomMember ?. roomId ) ?? this . props . room }
191
- key = { roomId ?? cardState ?. member ?. userId }
192
- onClose = { this . onClose }
193
- phase = { phase }
194
- verificationRequest = { cardState ?. verificationRequest }
195
- verificationRequestPromise = { cardState ?. verificationRequestPromise }
196
- />
197
- ) ;
199
+ if ( ! ! cardState ?. member ) {
200
+ const roomMember = cardState . member instanceof RoomMember ? cardState . member : undefined ;
201
+ card = (
202
+ < UserInfo
203
+ user = { cardState . member }
204
+ room = { this . context . getRoom ( roomMember ?. roomId ) ?? this . props . room }
205
+ key = { roomId ?? cardState . member . userId }
206
+ onClose = { this . onClose }
207
+ phase = { phase }
208
+ verificationRequest = { cardState . verificationRequest }
209
+ verificationRequestPromise = { cardState . verificationRequestPromise }
210
+ />
211
+ ) ;
212
+ }
198
213
break ;
199
214
}
200
215
case RightPanelPhases . Room3pidMemberInfo :
@@ -261,10 +276,10 @@ export default class RightPanel extends React.Component<IProps, IState> {
261
276
break ;
262
277
263
278
case RightPanelPhases . ThreadPanel :
264
- if ( ! ! roomId ) {
279
+ if ( ! ! this . props . room ) {
265
280
card = (
266
281
< ThreadPanel
267
- roomId = { roomId }
282
+ roomId = { this . props . room . roomId }
268
283
resizeNotifier = { this . props . resizeNotifier }
269
284
onClose = { this . onClose }
270
285
permalinkCreator = { this . props . permalinkCreator }
0 commit comments