You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-14 19:02:33 +03:00
Implement force state for features like in the proposal
This commit is contained in:
@@ -35,7 +35,8 @@ export class LabsSettingToggle extends React.Component {
|
||||
render() {
|
||||
const label = SettingsStore.getDisplayName(this.props.featureId);
|
||||
const value = SettingsStore.getValue(this.props.featureId);
|
||||
return <LabelledToggleSwitch value={value} label={label} onChange={this._onChange} />;
|
||||
const canChange = SettingsStore.canSetValue(this.props.featureId, null, SettingLevel.DEVICE);
|
||||
return <LabelledToggleSwitch value={value} label={label} onChange={this._onChange} disabled={!canChange} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import AccountSettingsHandler from "./handlers/AccountSettingsHandler";
|
||||
import RoomSettingsHandler from "./handlers/RoomSettingsHandler";
|
||||
import ConfigSettingsHandler from "./handlers/ConfigSettingsHandler";
|
||||
import { _t } from '../languageHandler';
|
||||
import SdkConfig from "../SdkConfig";
|
||||
import dis from '../dispatcher/dispatcher';
|
||||
import { ISetting, SETTINGS } from "./Settings";
|
||||
import LocalEchoWrapper from "./handlers/LocalEchoWrapper";
|
||||
@@ -435,6 +434,12 @@ export default class SettingsStore {
|
||||
throw new Error("Setting '" + settingName + "' does not appear to be a setting.");
|
||||
}
|
||||
|
||||
// When features are specified in the config.json, we force them as enabled or disabled.
|
||||
if (SettingsStore.isFeature(settingName)) {
|
||||
const configVal = SettingsStore.getValueAt(SettingLevel.CONFIG, settingName, roomId, true, true);
|
||||
if (configVal === true || configVal === false) return false;
|
||||
}
|
||||
|
||||
const handler = SettingsStore.getHandler(settingName, level);
|
||||
if (!handler) return false;
|
||||
return handler.canSetValue(settingName, roomId);
|
||||
|
||||
@@ -9,10 +9,7 @@
|
||||
"integrations_ui_url": "https://scalar.vector.im/",
|
||||
"integrations_rest_url": "https://scalar.vector.im/api",
|
||||
"bug_report_endpoint_url": "https://riot.im/bugreports/submit",
|
||||
"features": {
|
||||
"feature_groups": "labs",
|
||||
"feature_pinning": "labs"
|
||||
},
|
||||
"showLabsSettings": true,
|
||||
"default_federate": true,
|
||||
"welcomePageUrl": "home.html",
|
||||
"default_theme": "light",
|
||||
|
||||
Reference in New Issue
Block a user