Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Disable "Publish this room" option in invite only rooms #7441

Merged
merged 4 commits into from
Jan 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/components/views/room_settings/RoomPublishSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface IProps {

interface IState {
isRoomPublished: boolean;
isRoomPublishable: boolean;
}

@replaceableComponent("views.room_settings.RoomPublishSetting")
Expand All @@ -40,6 +41,7 @@ export default class RoomPublishSetting extends React.PureComponent<IProps, ISta

this.state = {
isRoomPublished: false,
isRoomPublishable: true,
};
}

Expand All @@ -63,14 +65,19 @@ export default class RoomPublishSetting extends React.PureComponent<IProps, ISta
client.getRoomDirectoryVisibility(this.props.roomId).then((result => {
this.setState({ isRoomPublished: result.visibility === 'public' });
}));

const room = client.getRoom(this.props.roomId);
if (room.getJoinRule() === "invite") {
this.setState({ isRoomPublishable: false });
}
aaronraimist marked this conversation as resolved.
Show resolved Hide resolved
}

render() {
const client = MatrixClientPeg.get();

const enabled = (
DirectoryCustomisations.requireCanonicalAliasAccessToPublish?.() === false ||
this.props.canSetCanonicalAlias
(DirectoryCustomisations.requireCanonicalAliasAccessToPublish?.() === false ||
this.props.canSetCanonicalAlias) && (this.state.isRoomPublishable || this.state.isRoomPublished)
);

return (
Expand Down