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,32 @@ 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 , useCallback , useContext , 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 { useEventEmitterState } from "../../hooks/useEventEmitter" ;
32
+ import { useMyRoomMembership } from "../../hooks/useRoomMembers" ;
33
+ import { useFeatureEnabled } from "../../hooks/useSettings" ;
34
+ import { useStateArray } from "../../hooks/useStateArray" ;
35
+ import { _t } from "../../languageHandler" ;
36
+ import PosthogTrackers from "../../PosthogTrackers" ;
37
+ import { inviteMultipleToRoom , showRoomInviteDialog } from "../../RoomInvite" ;
38
+ import { UIComponent } from "../../settings/UIFeature" ;
39
+ import { UPDATE_EVENT } from "../../stores/AsyncStore" ;
42
40
import RightPanelStore from "../../stores/right-panel/RightPanelStore" ;
43
41
import { RightPanelPhases } from "../../stores/right-panel/RightPanelStorePhases" ;
44
- import { useStateArray } from "../../hooks/useStateArray" ;
45
- import SpacePublicShare from "../views/spaces/SpacePublicShare" ;
42
+ import ResizeNotifier from "../../utils/ResizeNotifier" ;
46
43
import {
47
44
shouldShowSpaceInvite ,
48
45
shouldShowSpaceSettings ,
@@ -52,29 +49,33 @@ import {
52
49
showSpaceInvite ,
53
50
showSpaceSettings ,
54
51
} from "../../utils/space" ;
55
- import SpaceHierarchy , { showRoom } from "./SpaceHierarchy" ;
56
- import RoomFacePile from "../views/elements/RoomFacePile" ;
52
+ import RoomAvatar from "../views/avatars/RoomAvatar" ;
53
+ import { BetaPill } from "../views/beta/BetaCard" ;
54
+ import IconizedContextMenu , {
55
+ IconizedContextMenuOption ,
56
+ IconizedContextMenuOptionList ,
57
+ } from "../views/context_menus/IconizedContextMenu" ;
57
58
import {
58
59
AddExistingToSpace ,
59
60
defaultDmsRenderer ,
60
61
defaultRoomsRenderer ,
61
62
} from "../views/dialogs/AddExistingToSpaceDialog" ;
62
- import { ChevronFace , ContextMenuButton , useContextMenu } from "./ContextMenu" ;
63
- import IconizedContextMenu , {
64
- IconizedContextMenuOption ,
65
- IconizedContextMenuOptionList ,
66
- } from "../views/context_menus/IconizedContextMenu" ;
63
+ import AccessibleButton from "../views/elements/AccessibleButton" ;
67
64
import AccessibleTooltipButton from "../views/elements/AccessibleTooltipButton" ;
68
- import { BetaPill } from "../views/beta/BetaCard" ;
69
- import { SpaceFeedbackPrompt } from "../views/spaces/SpaceCreateMenu" ;
65
+ import ErrorBoundary from "../views/elements/ErrorBoundary" ;
66
+ import Field from "../views/elements/Field" ;
67
+ import RoomFacePile from "../views/elements/RoomFacePile" ;
68
+ import RoomName from "../views/elements/RoomName" ;
69
+ import RoomTopic from "../views/elements/RoomTopic" ;
70
+ import withValidation from "../views/elements/Validation" ;
70
71
import RoomInfoLine from "../views/rooms/RoomInfoLine" ;
71
72
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 " ;
73
+ import { SpaceFeedbackPrompt } from "../views/spaces/SpaceCreateMenu " ;
74
+ import SpacePublicShare from "../views/spaces/SpacePublicShare " ;
75
+ import { ChevronFace , ContextMenuButton , useContextMenu } from "./ContextMenu " ;
76
+ import MainSplit from './MainSplit' ;
77
+ import RightPanel from "./RightPanel " ;
78
+ import SpaceHierarchy , { showRoom } from "./SpaceHierarchy " ;
78
79
79
80
interface IProps {
80
81
space : Room ;
@@ -195,6 +196,13 @@ const SpaceLanding = ({ space }: { space: Room }) => {
195
196
const myMembership = useMyRoomMembership ( space ) ;
196
197
const userId = cli . getUserId ( ) ;
197
198
199
+ const storeIsShowingSpaceMembers = useCallback (
200
+ ( ) => RightPanelStore . instance . isOpenForRoom ( space . roomId )
201
+ && RightPanelStore . instance . currentCardForRoom ( space . roomId ) ?. phase === RightPanelPhases . SpaceMemberList ,
202
+ [ space . roomId ] ,
203
+ ) ;
204
+ const isShowingMembers = useEventEmitterState ( RightPanelStore . instance , UPDATE_EVENT , storeIsShowingSpaceMembers ) ;
205
+
198
206
let inviteButton ;
199
207
if ( shouldShowSpaceInvite ( space ) && shouldShowComponent ( UIComponent . InviteUsers ) ) {
200
208
inviteButton = (
@@ -249,7 +257,12 @@ const SpaceLanding = ({ space }: { space: Room }) => {
249
257
< div className = "mx_SpaceRoomView_landing_infoBar" >
250
258
< RoomInfoLine room = { space } />
251
259
< div className = "mx_SpaceRoomView_landing_infoBar_interactive" >
252
- < RoomFacePile room = { space } onlyKnownUsers = { false } numShown = { 7 } onClick = { onMembersClick } />
260
+ < RoomFacePile
261
+ room = { space }
262
+ onlyKnownUsers = { false }
263
+ numShown = { 7 }
264
+ onClick = { isShowingMembers ? undefined : onMembersClick }
265
+ />
253
266
{ inviteButton }
254
267
{ settingsButton }
255
268
</ div >
0 commit comments