diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index af48277bb6..2b933cd57a 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -55,9 +55,20 @@ module.exports = React.createClass({ power_levels_changed: false, tags_changed: false, tags: tags, - areNotifsMuted: areNotifsMuted + areNotifsMuted: areNotifsMuted, }; }, + + componentWillMount: function() { + var self = this; + MatrixClientPeg.get().getRoomVisibility( + this.props.room.roomId + ).done((result) => { + self.setState({ isRoomPublished: result.visibility === "public" }); + }, (err) => { + console.error("Failed to get room visibility: " + err); + }); + }, setName: function(name) { this.setState({ @@ -112,6 +123,13 @@ module.exports = React.createClass({ )); } + if (this.state.isRoomPublished !== originalState.isRoomPublished) { + promises.push(MatrixClientPeg.get().setRoomVisibility( + roomId, + this.state.isRoomPublished ? "public" : "private" + )); + } + if (this.state.join_rule !== originalState.join_rule) { promises.push(MatrixClientPeg.get().sendStateEvent( roomId, "m.room.join_rules", @@ -252,6 +270,30 @@ module.exports = React.createClass({ }); }, + _onRoomAccessRadioToggle: function(ev) { + var self = this; + switch (ev.target.value) { + case "invite_only": + self.setState({ + join_rule: "invite", + guest_access: "can_join", + }); + break; + case "public_no_guests": + self.setState({ + join_rule: "public", + guest_access: "forbidden", + }); + break; + case "public_with_guests": + self.setState({ + join_rule: "public", + guest_access: "can_join", + }); + break; + } + }, + _onToggle: function(keyName, checkedValue, uncheckedValue, ev) { console.log("Checkbox toggle: %s %s", keyName, ev.target.checked); var state = {}; @@ -427,7 +469,20 @@ module.exports = React.createClass({ // http://matrix.org/docs/spec/r0.0.0/client_server.html#id31 var historyVisibility = this.state.history_visibility || "shared"; - // FIXME: disable guests_read if the user hasn't turned on shared history + var addressWarning; + var aliasEvents = this.props.room.currentState.getStateEvents('m.room.aliases') || []; + var aliasCount = 0; + aliasEvents.forEach((event) => { + aliasCount += event.getContent().aliases.length; + }); + + if (this.state.join_rule === "public" && aliasCount == 0) { + addressWarning = +