From 761233c473efef1259e6c8c5c969d4d609877024 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 20 Sep 2019 17:43:14 +0200 Subject: [PATCH] add public switch --- .../views/dialogs/CreateRoomDialog.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/components/views/dialogs/CreateRoomDialog.js b/src/components/views/dialogs/CreateRoomDialog.js index e31d7304ea..10415680a7 100644 --- a/src/components/views/dialogs/CreateRoomDialog.js +++ b/src/components/views/dialogs/CreateRoomDialog.js @@ -31,6 +31,7 @@ export default createReactClass({ getInitialState() { const config = SdkConfig.get(); return { + isPublic: false, name: "", topic: "", noFederate: config.default_federate === false, @@ -41,6 +42,11 @@ export default createReactClass({ _roomCreateOptions() { const createOpts = {}; createOpts.name = this.state.name; + if (this.state.isPublic) { + createOpts.visibility = "public"; + createOpts.preset = "public_chat"; + // to prevent createRoom from enabling guest access + createOpts['initial_state'] = []; if (this.state.topic) { createOpts.topic = this.state.topic; } @@ -74,6 +80,10 @@ export default createReactClass({ this.setState({topic: ev.target.value}); }, + onPublicChange(isPublic) { + this.setState({isPublic}); + }, + onDetailsToggled(ev) { this.setState({detailsOpen: ev.target.open}); @@ -108,14 +118,26 @@ export default createReactClass({ const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); const Field = sdk.getComponent('views.elements.Field'); const LabelledToggleSwitch = sdk.getComponent('views.elements.LabelledToggleSwitch'); + let privateLabel; + let publicLabel; + if (this.state.isPublic) { + publicLabel = (

{_t("Set a room alias to easily share your room with other people.")}

); + } else { + privateLabel = (

{_t("This room is private, and can only be joined by invitation.")}

); + } + + const title = this.state.isPublic ? _t('Create a public room') : _t('Create a private room'); return (
this._nameFieldRef = ref} label={ _t('Name') } onChange={this.onNameChange} onValidate={this.onNameValidate} value={this.state.name} className="mx_CreateRoomDialog_name" /> + + { privateLabel } + { publicLabel }
{ this.state.detailsOpen ? _t('Hide advanced') : _t('Show advanced') }