Merge pull request #2553 from matrix-org/travis/settings/fixes-3
Misc fixes to settings
This commit is contained in:
commit
dca194f5e1
3 changed files with 45 additions and 22 deletions
|
@ -23,6 +23,7 @@ import sdk from "../../../../index";
|
||||||
import AccessibleButton from "../../elements/AccessibleButton";
|
import AccessibleButton from "../../elements/AccessibleButton";
|
||||||
import {MatrixClient} from "matrix-js-sdk";
|
import {MatrixClient} from "matrix-js-sdk";
|
||||||
import dis from "../../../../dispatcher";
|
import dis from "../../../../dispatcher";
|
||||||
|
import LabelledToggleSwitch from "../../elements/LabelledToggleSwitch";
|
||||||
|
|
||||||
export default class GeneralRoomSettingsTab extends React.Component {
|
export default class GeneralRoomSettingsTab extends React.Component {
|
||||||
static childContextTypes = {
|
static childContextTypes = {
|
||||||
|
@ -33,12 +34,40 @@ export default class GeneralRoomSettingsTab extends React.Component {
|
||||||
roomId: PropTypes.string.isRequired,
|
roomId: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
isRoomPublished: false, // loaded async
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
getChildContext() {
|
getChildContext() {
|
||||||
return {
|
return {
|
||||||
matrixClient: MatrixClientPeg.get(),
|
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) => {
|
_saveAliases = (e) => {
|
||||||
// TODO: Live modification?
|
// TODO: Live modification?
|
||||||
if (!this.refs.aliasSettings) return;
|
if (!this.refs.aliasSettings) return;
|
||||||
|
@ -67,6 +96,7 @@ export default class GeneralRoomSettingsTab extends React.Component {
|
||||||
const room = client.getRoom(this.props.roomId);
|
const room = client.getRoom(this.props.roomId);
|
||||||
|
|
||||||
const canSetAliases = true; // Previously, we arbitrarily only allowed admins to do this
|
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 canSetCanonical = room.currentState.mayClientSendStateEvent("m.room.canonical_alias", client);
|
||||||
const canonicalAliasEv = room.currentState.getStateEvents("m.room.canonical_alias", '');
|
const canonicalAliasEv = room.currentState.getStateEvents("m.room.canonical_alias", '');
|
||||||
const aliasEvents = room.currentState.getStateEvents("m.room.aliases");
|
const aliasEvents = room.currentState.getStateEvents("m.room.aliases");
|
||||||
|
@ -90,6 +120,14 @@ export default class GeneralRoomSettingsTab extends React.Component {
|
||||||
{_t("Save")}
|
{_t("Save")}
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
</div>
|
</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>
|
<span className='mx_SettingsTab_subheading'>{_t("Flair")}</span>
|
||||||
<div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'>
|
<div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'>
|
||||||
|
|
|
@ -16,11 +16,6 @@ limitations under the License.
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {_t} from "../../../../languageHandler";
|
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 ProfileSettings from "../ProfileSettings";
|
||||||
import EmailAddresses from "../EmailAddresses";
|
import EmailAddresses from "../EmailAddresses";
|
||||||
import PhoneNumbers from "../PhoneNumbers";
|
import PhoneNumbers from "../PhoneNumbers";
|
||||||
|
@ -37,10 +32,6 @@ const Modal = require("../../../../Modal");
|
||||||
const dis = require("../../../../dispatcher");
|
const dis = require("../../../../dispatcher");
|
||||||
|
|
||||||
export default class GeneralUserSettingsTab extends React.Component {
|
export default class GeneralUserSettingsTab extends React.Component {
|
||||||
static childContextTypes = {
|
|
||||||
matrixClient: PropTypes.instanceOf(MatrixClient),
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -50,12 +41,6 @@ export default class GeneralUserSettingsTab extends React.Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildContext() {
|
|
||||||
return {
|
|
||||||
matrixClient: MatrixClientPeg.get(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
_onLanguageChange = (newLanguage) => {
|
_onLanguageChange = (newLanguage) => {
|
||||||
if (this.state.language === newLanguage) return;
|
if (this.state.language === newLanguage) return;
|
||||||
|
|
||||||
|
@ -105,16 +90,10 @@ export default class GeneralUserSettingsTab extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
_renderProfileSection() {
|
_renderProfileSection() {
|
||||||
// HACK/TODO: Using DragDropContext feels wrong, but we need it.
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_SettingsTab_section">
|
<div className="mx_SettingsTab_section">
|
||||||
<span className="mx_SettingsTab_subheading">{_t("Profile")}</span>
|
<span className="mx_SettingsTab_subheading">{_t("Profile")}</span>
|
||||||
<ProfileSettings />
|
<ProfileSettings />
|
||||||
|
|
||||||
<span className="mx_SettingsTab_subheading">{_t("Flair")}</span>
|
|
||||||
<DragDropContext>
|
|
||||||
<GroupUserSettings />
|
|
||||||
</DragDropContext>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,13 @@ export default class VoiceSettingsTab extends React.Component {
|
||||||
this._refreshMediaDevices();
|
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({
|
this.setState({
|
||||||
mediaDevices: await CallMediaHandler.getDevices(),
|
mediaDevices: await CallMediaHandler.getDevices(),
|
||||||
activeAudioOutput: CallMediaHandler.getAudioOutput(),
|
activeAudioOutput: CallMediaHandler.getAudioOutput(),
|
||||||
|
|
Loading…
Reference in a new issue