Merge pull request #2553 from matrix-org/travis/settings/fixes-3
Misc fixes to settingspull/21833/head
						commit
						dca194f5e1
					
				|  | @ -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")} | ||||
|                     </AccessibleButton> | ||||
|                 </div> | ||||
|                 <div className='mx_SettingsTab_section'> | ||||
|                     <LabelledToggleSwitch value={this.state.isRoomPublished} | ||||
|                                           onChange={this.onRoomPublishChange} | ||||
|                                           disabled={!canActuallySetAliases} | ||||
|                                           label={_t("Publish this room to the public in %(domain)s's room directory?", { | ||||
|                                               domain: client.getDomain(), | ||||
|                                           })} /> | ||||
|                 </div> | ||||
| 
 | ||||
|                 <span className='mx_SettingsTab_subheading'>{_t("Flair")}</span> | ||||
|                 <div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'> | ||||
|  |  | |||
|  | @ -16,11 +16,6 @@ limitations under the License. | |||
| 
 | ||||
| import React from 'react'; | ||||
| import {_t} from "../../../../languageHandler"; | ||||
| import MatrixClientPeg from "../../../../MatrixClientPeg"; | ||||
| import GroupUserSettings from "../../groups/GroupUserSettings"; | ||||
| import PropTypes from "prop-types"; | ||||
| import {MatrixClient} from "matrix-js-sdk"; | ||||
| import { DragDropContext } from 'react-beautiful-dnd'; | ||||
| import ProfileSettings from "../ProfileSettings"; | ||||
| import EmailAddresses from "../EmailAddresses"; | ||||
| import PhoneNumbers from "../PhoneNumbers"; | ||||
|  | @ -37,10 +32,6 @@ const Modal = require("../../../../Modal"); | |||
| const dis = require("../../../../dispatcher"); | ||||
| 
 | ||||
| export default class GeneralUserSettingsTab extends React.Component { | ||||
|     static childContextTypes = { | ||||
|         matrixClient: PropTypes.instanceOf(MatrixClient), | ||||
|     }; | ||||
| 
 | ||||
|     constructor() { | ||||
|         super(); | ||||
| 
 | ||||
|  | @ -50,12 +41,6 @@ export default class GeneralUserSettingsTab extends React.Component { | |||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     getChildContext() { | ||||
|         return { | ||||
|             matrixClient: MatrixClientPeg.get(), | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     _onLanguageChange = (newLanguage) => { | ||||
|         if (this.state.language === newLanguage) return; | ||||
| 
 | ||||
|  | @ -105,16 +90,10 @@ export default class GeneralUserSettingsTab extends React.Component { | |||
|     }; | ||||
| 
 | ||||
|     _renderProfileSection() { | ||||
|         // HACK/TODO: Using DragDropContext feels wrong, but we need it.
 | ||||
|         return ( | ||||
|             <div className="mx_SettingsTab_section"> | ||||
|                 <span className="mx_SettingsTab_subheading">{_t("Profile")}</span> | ||||
|                 <ProfileSettings /> | ||||
| 
 | ||||
|                 <span className="mx_SettingsTab_subheading">{_t("Flair")}</span> | ||||
|                 <DragDropContext> | ||||
|                     <GroupUserSettings /> | ||||
|                 </DragDropContext> | ||||
|             </div> | ||||
|         ); | ||||
|     } | ||||
|  |  | |||
|  | @ -40,7 +40,13 @@ export default class VoiceSettingsTab extends React.Component { | |||
|         this._refreshMediaDevices(); | ||||
|     } | ||||
| 
 | ||||
|     _refreshMediaDevices = async () => { | ||||
|     _refreshMediaDevices = async (stream) => { | ||||
|         if (stream) { | ||||
|             // kill stream so that we don't leave it lingering around with webcam enabled etc
 | ||||
|             // as here we called gUM to ask user for permission to their device names only
 | ||||
|             stream.getTracks().forEach((track) => track.stop()); | ||||
|         } | ||||
| 
 | ||||
|         this.setState({ | ||||
|             mediaDevices: await CallMediaHandler.getDevices(), | ||||
|             activeAudioOutput: CallMediaHandler.getAudioOutput(), | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Travis Ralston
						Travis Ralston