From 5a2a2c5bdc3f51bc64fb44669b01de18aa12de1e Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 22 Mar 2016 12:26:38 +0000 Subject: [PATCH] fix up and factor out mayChangeRoomAccess and fix review feedback --- src/components/views/rooms/RoomSettings.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index bbe90ee059..74b326e987 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -56,7 +56,7 @@ module.exports = React.createClass({ tags_changed: false, tags: tags, areNotifsMuted: areNotifsMuted, - isRoomPublished: false, // updated in componentWillMount + // isRoomPublished: // set in componentWillMount }; }, @@ -284,6 +284,11 @@ module.exports = React.createClass({ case "invite_only": this.setState({ join_rule: "invite", + // we always set guests can_join here as it makes no sense to have + // an invite-only room that guests can't join. If you explicitly + // invite them, you clearly want them to join, whether they're a + // guest or not. In practice, guest_access should probably have + // been implemented as part of the join_rules enum. guest_access: "can_join", }); break; @@ -330,6 +335,13 @@ module.exports = React.createClass({ }); }, + mayChangeRoomAccess: function() { + var cli = MatrixClientPeg.get(); + var roomState = this.props.room.currentState; + return (roomState.mayClientSendStateEvent("m.room.join_rules", cli) && + roomState.mayClientSendStateEvent("m.room.guest_access", cli)) + }, + render: function() { // TODO: go through greying out things you don't have permission to change // (or turning them into informative stuff) @@ -519,23 +531,21 @@ module.exports = React.createClass({ { inviteGuestWarning }