1
1
/*
2
- Copyright 2021 The Matrix.org Foundation C.I.C.
2
+ Copyright 2021-2022 The Matrix.org Foundation C.I.C.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
@@ -14,35 +14,31 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- import React , { RefObject , useContext , useRef , useState } from "react" ;
18
17
import { EventType , RoomType } from "matrix-js-sdk/src/@types/event" ;
19
18
import { JoinRule , Preset } from "matrix-js-sdk/src/@types/partials" ;
20
- import { Room , RoomEvent } from "matrix-js-sdk/src/models/room" ;
21
19
import { logger } from "matrix-js-sdk/src/logger" ;
20
+ import { Room , RoomEvent } from "matrix-js-sdk/src/models/room" ;
21
+ import React , { RefObject , useContext , useEffect , useRef , useState } from "react" ;
22
22
23
23
import MatrixClientContext from "../../contexts/MatrixClientContext" ;
24
- import RoomAvatar from "../views/avatars/RoomAvatar" ;
25
- import { _t } from "../../languageHandler" ;
26
- import AccessibleButton from "../views/elements/AccessibleButton" ;
27
- import RoomName from "../views/elements/RoomName" ;
28
- import RoomTopic from "../views/elements/RoomTopic" ;
29
- import { inviteMultipleToRoom , showRoomInviteDialog } from "../../RoomInvite" ;
30
- import { useFeatureEnabled } from "../../hooks/useSettings" ;
31
24
import createRoom , { IOpts } from "../../createRoom" ;
32
- import Field from "../views/elements/Field" ;
33
- import withValidation from "../views/elements/Validation" ;
34
- import * as Email from "../../email" ;
35
- import defaultDispatcher from "../../dispatcher/dispatcher" ;
25
+ import { shouldShowComponent } from "../../customisations/helpers/UIComponents" ;
36
26
import { Action } from "../../dispatcher/actions" ;
37
- import ResizeNotifier from "../../utils/ResizeNotifier" ;
38
- import MainSplit from './MainSplit' ;
39
- import ErrorBoundary from "../views/elements/ErrorBoundary" ;
27
+ import defaultDispatcher from "../../dispatcher/dispatcher" ;
40
28
import { ActionPayload } from "../../dispatcher/payloads" ;
41
- import RightPanel from "./RightPanel" ;
29
+ import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload" ;
30
+ import * as Email from "../../email" ;
31
+ import { useMyRoomMembership } from "../../hooks/useRoomMembers" ;
32
+ import { useFeatureEnabled } from "../../hooks/useSettings" ;
33
+ import { useStateArray } from "../../hooks/useStateArray" ;
34
+ import { _t } from "../../languageHandler" ;
35
+ import PosthogTrackers from "../../PosthogTrackers" ;
36
+ import { inviteMultipleToRoom , showRoomInviteDialog } from "../../RoomInvite" ;
37
+ import { UIComponent } from "../../settings/UIFeature" ;
38
+ import { UPDATE_EVENT } from "../../stores/AsyncStore" ;
42
39
import RightPanelStore from "../../stores/right-panel/RightPanelStore" ;
43
40
import { RightPanelPhases } from "../../stores/right-panel/RightPanelStorePhases" ;
44
- import { useStateArray } from "../../hooks/useStateArray" ;
45
- import SpacePublicShare from "../views/spaces/SpacePublicShare" ;
41
+ import ResizeNotifier from "../../utils/ResizeNotifier" ;
46
42
import {
47
43
shouldShowSpaceInvite ,
48
44
shouldShowSpaceSettings ,
@@ -52,29 +48,33 @@ import {
52
48
showSpaceInvite ,
53
49
showSpaceSettings ,
54
50
} from "../../utils/space" ;
55
- import SpaceHierarchy , { showRoom } from "./SpaceHierarchy" ;
56
- import RoomFacePile from "../views/elements/RoomFacePile" ;
51
+ import RoomAvatar from "../views/avatars/RoomAvatar" ;
52
+ import { BetaPill } from "../views/beta/BetaCard" ;
53
+ import IconizedContextMenu , {
54
+ IconizedContextMenuOption ,
55
+ IconizedContextMenuOptionList ,
56
+ } from "../views/context_menus/IconizedContextMenu" ;
57
57
import {
58
58
AddExistingToSpace ,
59
59
defaultDmsRenderer ,
60
60
defaultRoomsRenderer ,
61
61
} from "../views/dialogs/AddExistingToSpaceDialog" ;
62
- import { ChevronFace , ContextMenuButton , useContextMenu } from "./ContextMenu" ;
63
- import IconizedContextMenu , {
64
- IconizedContextMenuOption ,
65
- IconizedContextMenuOptionList ,
66
- } from "../views/context_menus/IconizedContextMenu" ;
62
+ import AccessibleButton from "../views/elements/AccessibleButton" ;
67
63
import AccessibleTooltipButton from "../views/elements/AccessibleTooltipButton" ;
68
- import { BetaPill } from "../views/beta/BetaCard" ;
69
- import { SpaceFeedbackPrompt } from "../views/spaces/SpaceCreateMenu" ;
64
+ import ErrorBoundary from "../views/elements/ErrorBoundary" ;
65
+ import Field from "../views/elements/Field" ;
66
+ import RoomFacePile from "../views/elements/RoomFacePile" ;
67
+ import RoomName from "../views/elements/RoomName" ;
68
+ import RoomTopic from "../views/elements/RoomTopic" ;
69
+ import withValidation from "../views/elements/Validation" ;
70
70
import RoomInfoLine from "../views/rooms/RoomInfoLine" ;
71
71
import RoomPreviewCard from "../views/rooms/RoomPreviewCard" ;
72
- import { useMyRoomMembership } from "../../hooks/useRoomMembers " ;
73
- import { shouldShowComponent } from "../../customisations/helpers/UIComponents " ;
74
- import { UIComponent } from "../../settings/UIFeature " ;
75
- import { UPDATE_EVENT } from "../../stores/AsyncStore" ;
76
- import PosthogTrackers from "../../PosthogTrackers " ;
77
- import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload " ;
72
+ import { SpaceFeedbackPrompt } from "../views/spaces/SpaceCreateMenu " ;
73
+ import SpacePublicShare from "../views/spaces/SpacePublicShare " ;
74
+ import { ChevronFace , ContextMenuButton , useContextMenu } from "./ContextMenu " ;
75
+ import MainSplit from './MainSplit' ;
76
+ import RightPanel from "./RightPanel " ;
77
+ import SpaceHierarchy , { showRoom } from "./SpaceHierarchy " ;
78
78
79
79
interface IProps {
80
80
space : Room ;
@@ -190,11 +190,25 @@ const SpaceLandingAddButton = ({ space }) => {
190
190
</ > ;
191
191
} ;
192
192
193
+ function storeIsShowingSpaceMembers ( space : Room ) : boolean {
194
+ return RightPanelStore . instance . isOpenForRoom ( space . roomId ) &&
195
+ RightPanelStore . instance . currentCardForRoom ( space . roomId ) ?. phase === RightPanelPhases . SpaceMemberList ;
196
+ }
197
+
193
198
const SpaceLanding = ( { space } : { space : Room } ) => {
194
199
const cli = useContext ( MatrixClientContext ) ;
195
200
const myMembership = useMyRoomMembership ( space ) ;
196
201
const userId = cli . getUserId ( ) ;
197
202
203
+ const [ isShowingMembers , setIsShowingMembers ] = useState < boolean > ( storeIsShowingSpaceMembers ( space ) ) ;
204
+ useEffect ( ( ) => {
205
+ const listener = ( ) => setIsShowingMembers ( storeIsShowingSpaceMembers ( space ) ) ;
206
+ RightPanelStore . instance . addListener ( UPDATE_EVENT , listener ) ;
207
+ return ( ) => {
208
+ RightPanelStore . instance . removeListener ( UPDATE_EVENT , listener ) ;
209
+ } ;
210
+ } , [ space ] ) ;
211
+
198
212
let inviteButton ;
199
213
if ( shouldShowSpaceInvite ( space ) && shouldShowComponent ( UIComponent . InviteUsers ) ) {
200
214
inviteButton = (
@@ -249,7 +263,12 @@ const SpaceLanding = ({ space }: { space: Room }) => {
249
263
< div className = "mx_SpaceRoomView_landing_infoBar" >
250
264
< RoomInfoLine room = { space } />
251
265
< div className = "mx_SpaceRoomView_landing_infoBar_interactive" >
252
- < RoomFacePile room = { space } onlyKnownUsers = { false } numShown = { 7 } onClick = { onMembersClick } />
266
+ < RoomFacePile
267
+ room = { space }
268
+ onlyKnownUsers = { false }
269
+ numShown = { 7 }
270
+ onClick = { isShowingMembers ? undefined : onMembersClick }
271
+ />
253
272
{ inviteButton }
254
273
{ settingsButton }
255
274
</ div >
0 commit comments