diff --git a/src/components/views/settings/tabs/GeneralRoomSettingsTab.js b/src/components/views/settings/tabs/GeneralRoomSettingsTab.js index 2f7ef725b7..75373a69bc 100644 --- a/src/components/views/settings/tabs/GeneralRoomSettingsTab.js +++ b/src/components/views/settings/tabs/GeneralRoomSettingsTab.js @@ -23,6 +23,7 @@ import sdk from "../../../../index"; import AccessibleButton from "../../elements/AccessibleButton"; import {MatrixClient} from "matrix-js-sdk"; import dis from "../../../../dispatcher"; +import LabelledToggleSwitch from "../../elements/LabelledToggleSwitch"; export default class GeneralRoomSettingsTab extends React.Component { static childContextTypes = { @@ -33,12 +34,40 @@ export default class GeneralRoomSettingsTab extends React.Component { roomId: PropTypes.string.isRequired, }; + constructor() { + super(); + + this.state = { + isRoomPublished: false, // loaded async + }; + } + getChildContext() { return { matrixClient: MatrixClientPeg.get(), }; } + componentWillMount() { + MatrixClientPeg.get().getRoomDirectoryVisibility(this.props.roomId).then((result => { + this.setState({isRoomPublished: result.visibility === 'public'}); + })); + } + + onRoomPublishChange = (e) => { + const valueBefore = this.state.isRoomPublished; + const newValue = !valueBefore; + this.setState({isRoomPublished: newValue}); + + MatrixClientPeg.get().setRoomDirectoryVisibility( + this.props.roomId, + newValue ? 'public' : 'private', + ).catch(() => { + // Roll back the local echo on the change + this.setState({isRoomPublished: valueBefore}); + }); + }; + _saveAliases = (e) => { // TODO: Live modification? if (!this.refs.aliasSettings) return; @@ -67,6 +96,7 @@ export default class GeneralRoomSettingsTab extends React.Component { const room = client.getRoom(this.props.roomId); const canSetAliases = true; // Previously, we arbitrarily only allowed admins to do this + const canActuallySetAliases = room.currentState.mayClientSendStateEvent("m.room.aliases", client); const canSetCanonical = room.currentState.mayClientSendStateEvent("m.room.canonical_alias", client); const canonicalAliasEv = room.currentState.getStateEvents("m.room.canonical_alias", ''); const aliasEvents = room.currentState.getStateEvents("m.room.aliases"); @@ -90,6 +120,14 @@ export default class GeneralRoomSettingsTab extends React.Component { {_t("Save")} +
+ +
{_t("Flair")}