mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-18 14:44:58 +08:00
Fix space invite edge cases
This commit is contained in:
parent
c3bac33b9d
commit
d6cab320e9
@ -111,6 +111,7 @@ import { PosthogAnalytics } from '../../PosthogAnalytics';
|
|||||||
import { initSentry } from "../../sentry";
|
import { initSentry } from "../../sentry";
|
||||||
|
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
import { showSpaceInvite } from "../../utils/space";
|
||||||
|
|
||||||
/** constants for MatrixChat.state.view */
|
/** constants for MatrixChat.state.view */
|
||||||
export enum Views {
|
export enum Views {
|
||||||
@ -741,9 +742,15 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||||||
case 'view_create_chat':
|
case 'view_create_chat':
|
||||||
showStartChatInviteDialog(payload.initialText || "");
|
showStartChatInviteDialog(payload.initialText || "");
|
||||||
break;
|
break;
|
||||||
case 'view_invite':
|
case 'view_invite': {
|
||||||
showRoomInviteDialog(payload.roomId);
|
const room = MatrixClientPeg.get().getRoom(payload.roomId);
|
||||||
|
if (room?.isSpaceRoom()) {
|
||||||
|
showSpaceInvite(room);
|
||||||
|
} else {
|
||||||
|
showRoomInviteDialog(payload.roomId);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'view_last_screen':
|
case 'view_last_screen':
|
||||||
// This function does what we want, despite the name. The idea is that it shows
|
// 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
|
// the last room we were looking at or some reasonable default/guess. We don't
|
||||||
|
@ -52,6 +52,7 @@ import {
|
|||||||
showAddExistingRooms,
|
showAddExistingRooms,
|
||||||
showCreateNewRoom,
|
showCreateNewRoom,
|
||||||
showCreateNewSubspace,
|
showCreateNewSubspace,
|
||||||
|
showSpaceInvite,
|
||||||
showSpaceSettings,
|
showSpaceSettings,
|
||||||
} from "../../utils/space";
|
} from "../../utils/space";
|
||||||
import SpaceHierarchy, { showRoom } from "./SpaceHierarchy";
|
import SpaceHierarchy, { showRoom } from "./SpaceHierarchy";
|
||||||
@ -405,19 +406,19 @@ const SpaceLandingAddButton = ({ space }) => {
|
|||||||
</>;
|
</>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SpaceLanding = ({ space }) => {
|
const SpaceLanding = ({ space }: { space: Room }) => {
|
||||||
const cli = useContext(MatrixClientContext);
|
const cli = useContext(MatrixClientContext);
|
||||||
const myMembership = useMyRoomMembership(space);
|
const myMembership = useMyRoomMembership(space);
|
||||||
const userId = cli.getUserId();
|
const userId = cli.getUserId();
|
||||||
|
|
||||||
let inviteButton;
|
let inviteButton;
|
||||||
if (myMembership === "join" && space.canInvite(userId)) {
|
if ((myMembership === "join" && space.canInvite(userId)) || space.getJoinRule() === JoinRule.Public) {
|
||||||
inviteButton = (
|
inviteButton = (
|
||||||
<AccessibleButton
|
<AccessibleButton
|
||||||
kind="primary"
|
kind="primary"
|
||||||
className="mx_SpaceRoomView_landing_inviteButton"
|
className="mx_SpaceRoomView_landing_inviteButton"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
showRoomInviteDialog(space.roomId);
|
showSpaceInvite(space);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{ _t("Invite") }
|
{ _t("Invite") }
|
||||||
|
@ -44,6 +44,7 @@ import MemberTile from "./MemberTile";
|
|||||||
import BaseAvatar from '../avatars/BaseAvatar';
|
import BaseAvatar from '../avatars/BaseAvatar';
|
||||||
import { throttle } from 'lodash';
|
import { throttle } from 'lodash';
|
||||||
import SpaceStore from "../../../stores/SpaceStore";
|
import SpaceStore from "../../../stores/SpaceStore";
|
||||||
|
import { JoinRule } from "matrix-js-sdk/src/@types/partials";
|
||||||
|
|
||||||
const getSearchQueryLSKey = (roomId: string) => `mx_MemberList_searchQuarry_${roomId}`;
|
const getSearchQueryLSKey = (roomId: string) => `mx_MemberList_searchQuarry_${roomId}`;
|
||||||
|
|
||||||
@ -169,7 +170,11 @@ export default class MemberList extends React.Component<IProps, IState> {
|
|||||||
private get canInvite(): boolean {
|
private get canInvite(): boolean {
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
const room = cli.getRoom(this.props.roomId);
|
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<RoomMember>): IState {
|
private getMembersState(members: Array<RoomMember>): IState {
|
||||||
|
@ -49,6 +49,7 @@ import { showAddExistingRooms, showCreateNewRoom, showSpaceInvite } from "../../
|
|||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import RoomAvatar from "../avatars/RoomAvatar";
|
import RoomAvatar from "../avatars/RoomAvatar";
|
||||||
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
|
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
|
||||||
|
import { JoinRule } from "matrix-js-sdk/src/@types/partials";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
onKeyDown: (ev: React.KeyboardEvent) => void;
|
onKeyDown: (ev: React.KeyboardEvent) => void;
|
||||||
@ -521,19 +522,23 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
|||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
</div>;
|
</div>;
|
||||||
} else if (
|
} 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 spaceName = this.props.activeSpace.name;
|
||||||
|
const canInvite = this.props.activeSpace?.canInvite(userId) ||
|
||||||
|
this.props.activeSpace?.getJoinRule() === JoinRule.Public;
|
||||||
explorePrompt = <div className="mx_RoomList_explorePrompt">
|
explorePrompt = <div className="mx_RoomList_explorePrompt">
|
||||||
<div>{ _t("Quick actions") }</div>
|
<div>{ _t("Quick actions") }</div>
|
||||||
{ this.props.activeSpace.canInvite(userId) && <AccessibleTooltipButton
|
{ canInvite && <AccessibleTooltipButton
|
||||||
className="mx_RoomList_explorePrompt_spaceInvite"
|
className="mx_RoomList_explorePrompt_spaceInvite"
|
||||||
onClick={this.onSpaceInviteClick}
|
onClick={this.onSpaceInviteClick}
|
||||||
title={_t("Invite to %(spaceName)s", { spaceName })}
|
title={_t("Invite to %(spaceName)s", { spaceName })}
|
||||||
>
|
>
|
||||||
{ _t("Invite people") }
|
{ _t("Invite people") }
|
||||||
</AccessibleTooltipButton> }
|
</AccessibleTooltipButton> }
|
||||||
{ this.props.activeSpace.getMyMembership() === "join" && <AccessibleTooltipButton
|
{ this.props.activeSpace?.getMyMembership() === "join" && <AccessibleTooltipButton
|
||||||
className="mx_RoomList_explorePrompt_spaceExplore"
|
className="mx_RoomList_explorePrompt_spaceExplore"
|
||||||
onClick={this.onExplore}
|
onClick={this.onExplore}
|
||||||
title={_t("Explore %(spaceName)s", { spaceName })}
|
title={_t("Explore %(spaceName)s", { spaceName })}
|
||||||
|
Loading…
Reference in New Issue
Block a user