@@ -127,8 +127,17 @@ const useMyRoomMembership = (room: Room) => {
127
127
return membership ;
128
128
} ;
129
129
130
- const SpaceInfo = ( { space } ) => {
130
+ const SpaceInfo = ( { space } : { space : Room } ) => {
131
+ const summary = useAsyncMemo ( ( ) => {
132
+ if ( space . getMyMembership ( ) !== "invite" ) return ;
133
+ try {
134
+ return space . client . getRoomSummary ( space . roomId ) ;
135
+ } catch ( e ) {
136
+ return null ;
137
+ }
138
+ } , [ space ] ) ;
131
139
const joinRule = useRoomState ( space , state => state . getJoinRule ( ) ) ;
140
+ const membership = useMyRoomMembership ( space ) ;
132
141
133
142
let visibilitySection ;
134
143
if ( joinRule === "public" ) {
@@ -141,12 +150,18 @@ const SpaceInfo = ({ space }) => {
141
150
</ span > ;
142
151
}
143
152
144
- return < div className = "mx_SpaceRoomView_info" >
145
- { visibilitySection }
146
- { joinRule === "public" && < RoomMemberCount room = { space } >
153
+ let memberSection ;
154
+ if ( membership === "invite" && summary ) {
155
+ // Don't trust local state and instead use the summary API
156
+ memberSection = < span className = "mx_SpaceRoomView_info_memberCount" >
157
+ { _t ( "%(count)s members" , { count : summary . num_joined_members } ) }
158
+ </ span > ;
159
+ } else if ( summary === null ) {
160
+ memberSection = < RoomMemberCount room = { space } >
147
161
{ ( count ) => count > 0 ? (
148
162
< AccessibleButton
149
163
kind = "link"
164
+ className = "mx_SpaceRoomView_info_memberCount"
150
165
onClick = { ( ) => {
151
166
defaultDispatcher . dispatch < SetRightPanelPhasePayload > ( {
152
167
action : Action . SetRightPanelPhase ,
@@ -158,7 +173,12 @@ const SpaceInfo = ({ space }) => {
158
173
{ _t ( "%(count)s members" , { count } ) }
159
174
</ AccessibleButton >
160
175
) : null }
161
- </ RoomMemberCount > }
176
+ </ RoomMemberCount > ;
177
+ }
178
+
179
+ return < div className = "mx_SpaceRoomView_info" >
180
+ { visibilitySection }
181
+ { memberSection }
162
182
</ div > ;
163
183
} ;
164
184
0 commit comments