diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 90ac47ffb5..d649c702bc 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -111,6 +111,7 @@ import { PosthogAnalytics } from '../../PosthogAnalytics'; import { initSentry } from "../../sentry"; import { logger } from "matrix-js-sdk/src/logger"; +import { showSpaceInvite } from "../../utils/space"; /** constants for MatrixChat.state.view */ export enum Views { @@ -741,9 +742,15 @@ export default class MatrixChat extends React.PureComponent { case 'view_create_chat': showStartChatInviteDialog(payload.initialText || ""); break; - case 'view_invite': - showRoomInviteDialog(payload.roomId); + case 'view_invite': { + const room = MatrixClientPeg.get().getRoom(payload.roomId); + if (room?.isSpaceRoom()) { + showSpaceInvite(room); + } else { + showRoomInviteDialog(payload.roomId); + } break; + } case 'view_last_screen': // This function does what we want, despite the name. The idea is that it shows // the last room we were looking at or some reasonable default/guess. We don't diff --git a/src/components/structures/SpaceRoomView.tsx b/src/components/structures/SpaceRoomView.tsx index 54dde2e891..d3a0eca608 100644 --- a/src/components/structures/SpaceRoomView.tsx +++ b/src/components/structures/SpaceRoomView.tsx @@ -52,6 +52,7 @@ import { showAddExistingRooms, showCreateNewRoom, showCreateNewSubspace, + showSpaceInvite, showSpaceSettings, } from "../../utils/space"; import SpaceHierarchy, { showRoom } from "./SpaceHierarchy"; @@ -407,19 +408,21 @@ const SpaceLandingAddButton = ({ space }) => { ; }; -const SpaceLanding = ({ space }) => { +const SpaceLanding = ({ space }: { space: Room }) => { const cli = useContext(MatrixClientContext); const myMembership = useMyRoomMembership(space); const userId = cli.getUserId(); let inviteButton; - if (myMembership === "join" && space.canInvite(userId) && shouldShowComponent(UIComponent.InviteUsers)) { + if (((myMembership === "join" && space.canInvite(userId)) || space.getJoinRule() === JoinRule.Public) && + shouldShowComponent(UIComponent.InviteUsers) + ) { inviteButton = ( { - showRoomInviteDialog(space.roomId); + showSpaceInvite(space); }} > { _t("Invite") } diff --git a/src/components/views/rooms/MemberList.tsx b/src/components/views/rooms/MemberList.tsx index b31b09ab24..139ec46e6f 100644 --- a/src/components/views/rooms/MemberList.tsx +++ b/src/components/views/rooms/MemberList.tsx @@ -46,6 +46,7 @@ import { throttle } from 'lodash'; import SpaceStore from "../../../stores/SpaceStore"; import { shouldShowComponent } from "../../../customisations/helpers/UIComponents"; import { UIComponent } from "../../../settings/UIFeature"; +import { JoinRule } from "matrix-js-sdk/src/@types/partials"; const getSearchQueryLSKey = (roomId: string) => `mx_MemberList_searchQuarry_${roomId}`; @@ -171,7 +172,11 @@ export default class MemberList extends React.Component { private get canInvite(): boolean { const cli = MatrixClientPeg.get(); const room = cli.getRoom(this.props.roomId); - return room && room.canInvite(cli.getUserId()); + + return ( + room?.canInvite(cli.getUserId()) || + (room?.isSpaceRoom() && room.getJoinRule() === JoinRule.Public) + ); } private getMembersState(members: Array): IState { diff --git a/src/components/views/rooms/RoomList.tsx b/src/components/views/rooms/RoomList.tsx index 4c9690fefc..90250f2d77 100644 --- a/src/components/views/rooms/RoomList.tsx +++ b/src/components/views/rooms/RoomList.tsx @@ -51,6 +51,7 @@ import RoomAvatar from "../avatars/RoomAvatar"; import AccessibleTooltipButton from "../elements/AccessibleTooltipButton"; import { shouldShowComponent } from "../../../customisations/helpers/UIComponents"; import { UIComponent } from "../../../settings/UIFeature"; +import { JoinRule } from "matrix-js-sdk/src/@types/partials"; interface IProps { onKeyDown: (ev: React.KeyboardEvent) => void; @@ -529,19 +530,23 @@ export default class RoomList extends React.PureComponent { ; } else if ( - this.props.activeSpace?.canInvite(userId) || this.props.activeSpace?.getMyMembership() === "join" + this.props.activeSpace?.canInvite(userId) || + this.props.activeSpace?.getMyMembership() === "join" || + this.props.activeSpace?.getJoinRule() === JoinRule.Public ) { const spaceName = this.props.activeSpace.name; + const canInvite = this.props.activeSpace?.canInvite(userId) || + this.props.activeSpace?.getJoinRule() === JoinRule.Public; explorePrompt =
{ _t("Quick actions") }
- { this.props.activeSpace.canInvite(userId) && { _t("Invite people") } } - { this.props.activeSpace.getMyMembership() === "join" &&