mirror of https://github.com/vector-im/riot-web
parent
ae10a11ac4
commit
e8acb0e102
|
@ -126,16 +126,8 @@ const CRYPTO_SETTINGS_LABELS = [
|
||||||
// packaged up in a single directory, and/or located at the application layer.
|
// packaged up in a single directory, and/or located at the application layer.
|
||||||
// But for now for expedience we just hardcode them here.
|
// But for now for expedience we just hardcode them here.
|
||||||
const THEMES = [
|
const THEMES = [
|
||||||
{
|
{ label: _td('Light theme'), value: 'light' },
|
||||||
id: 'theme',
|
{ label: _td('Dark theme'), value: 'dark' },
|
||||||
label: _td('Light theme'),
|
|
||||||
value: 'light',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'theme',
|
|
||||||
label: _td('Dark theme'),
|
|
||||||
value: 'dark',
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const IgnoredUser = React.createClass({
|
const IgnoredUser = React.createClass({
|
||||||
|
@ -719,12 +711,11 @@ module.exports = React.createClass({
|
||||||
return <div className="mx_UserSettings_toggle" key={setting.id}>
|
return <div className="mx_UserSettings_toggle" key={setting.id}>
|
||||||
<input id={setting.id}
|
<input id={setting.id}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
// TODO: {Travis} Support atLevel=account
|
defaultChecked={SettingsStore.getValueAt("account", setting.id)}
|
||||||
defaultChecked={SettingsStore.getValue(setting.id)}
|
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
/>
|
/>
|
||||||
<label htmlFor={setting.id}>
|
<label htmlFor={setting.id}>
|
||||||
{ SettingsStore.getDisplayName(setting.id) }
|
{ setting.label || SettingsStore.getDisplayName(setting.id) }
|
||||||
</label>
|
</label>
|
||||||
</div>;
|
</div>;
|
||||||
},
|
},
|
||||||
|
@ -734,23 +725,22 @@ module.exports = React.createClass({
|
||||||
// to rebind the onChange each time we render
|
// to rebind the onChange each time we render
|
||||||
const onChange = (e) => {
|
const onChange = (e) => {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
SettingsStore.setValue(setting.id, null, "account", setting.value);
|
SettingsStore.setValue("theme", null, "account", setting.value);
|
||||||
}
|
}
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'set_theme',
|
action: 'set_theme',
|
||||||
value: setting.value,
|
value: setting.value,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return <div className="mx_UserSettings_toggle" key={setting.id + "_" + setting.value}>
|
return <div className="mx_UserSettings_toggle" key={"theme_" + setting.value}>
|
||||||
<input id={setting.id + "_" + setting.value}
|
<input id={"theme_" + setting.value}
|
||||||
type="radio"
|
type="radio"
|
||||||
name={setting.id}
|
name="theme"
|
||||||
value={setting.value}
|
value={setting.value}
|
||||||
// TODO: {Travis} Support atLevel=account
|
checked={SettingsStore.getValueAt("account", "theme") === setting.value}
|
||||||
checked={SettingsStore.getValue(setting.id) === setting.value}
|
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
/>
|
/>
|
||||||
<label htmlFor={setting.id + "_" + setting.value}>
|
<label htmlFor={"theme_" + setting.value}>
|
||||||
{ _t(setting.label) }
|
{ _t(setting.label) }
|
||||||
</label>
|
</label>
|
||||||
</div>;
|
</div>;
|
||||||
|
|
|
@ -291,6 +291,28 @@ export default class SettingsStore {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a setting's value at the given level.
|
||||||
|
* @param {"device"|"room-device"|"room-account"|"account"|"room"} level The lvel to
|
||||||
|
* look at.
|
||||||
|
* @param {string} settingName The name of the setting to read.
|
||||||
|
* @param {String} roomId The room ID to read the setting value in, may be null.
|
||||||
|
* @return {*} The value, or null if not found.
|
||||||
|
*/
|
||||||
|
static getValueAt(level, settingName, roomId=null) {
|
||||||
|
// We specifically handle features as they have the possibility of being forced on.
|
||||||
|
if (SettingsStore.isFeature(settingName)) {
|
||||||
|
const configValue = SettingsStore._getFeatureState(settingName);
|
||||||
|
if (configValue === "enable") return true;
|
||||||
|
if (configValue === "disable") return false;
|
||||||
|
// else let it fall through the default process
|
||||||
|
}
|
||||||
|
|
||||||
|
const handler = SettingsStore._getHandler(settingName, level);
|
||||||
|
if (!handler) return null;
|
||||||
|
return handler.getValue(settingName, roomId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value for a setting. The room ID is optional if the setting is not being
|
* Sets the value for a setting. The room ID is optional if the setting is not being
|
||||||
* set for a particular room, otherwise it should be supplied. The value may be null
|
* set for a particular room, otherwise it should be supplied. The value may be null
|
||||||
|
|
Loading…
Reference in New Issue