Fix space invite edge cases
This commit is contained in:
parent
c3bac33b9d
commit
d6cab320e9
4 changed files with 27 additions and 9 deletions
|
@ -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<IProps, IState> {
|
|||
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
|
||||
|
|
|
@ -52,6 +52,7 @@ import {
|
|||
showAddExistingRooms,
|
||||
showCreateNewRoom,
|
||||
showCreateNewSubspace,
|
||||
showSpaceInvite,
|
||||
showSpaceSettings,
|
||||
} from "../../utils/space";
|
||||
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 myMembership = useMyRoomMembership(space);
|
||||
const userId = cli.getUserId();
|
||||
|
||||
let inviteButton;
|
||||
if (myMembership === "join" && space.canInvite(userId)) {
|
||||
if ((myMembership === "join" && space.canInvite(userId)) || space.getJoinRule() === JoinRule.Public) {
|
||||
inviteButton = (
|
||||
<AccessibleButton
|
||||
kind="primary"
|
||||
className="mx_SpaceRoomView_landing_inviteButton"
|
||||
onClick={() => {
|
||||
showRoomInviteDialog(space.roomId);
|
||||
showSpaceInvite(space);
|
||||
}}
|
||||
>
|
||||
{ _t("Invite") }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue