Update LabsUserSettings for new feature behaviour

pull/21833/head
Travis Ralston 2020-08-17 13:19:15 -06:00
parent 96087d61f6
commit eda4e24926
2 changed files with 10 additions and 2 deletions

View File

@ -28,7 +28,7 @@ export class LabsSettingToggle extends React.Component {
}; };
_onChange = async (checked) => { _onChange = async (checked) => {
await SettingsStore.setFeatureEnabled(this.props.featureId, checked); await SettingsStore.setValue(this.props.featureId, null, SettingLevel.DEVICE, checked);
this.forceUpdate(); this.forceUpdate();
}; };
@ -46,7 +46,7 @@ export default class LabsUserSettingsTab extends React.Component {
render() { render() {
const SettingsFlag = sdk.getComponent("views.elements.SettingsFlag"); const SettingsFlag = sdk.getComponent("views.elements.SettingsFlag");
const flags = SettingsStore.getLabsFeatures().map(f => <LabsSettingToggle featureId={f} key={f} />); const flags = SettingsStore.getFeatureSettingNames().map(f => <LabsSettingToggle featureId={f} key={f} />);
return ( return (
<div className="mx_SettingsTab"> <div className="mx_SettingsTab">
<div className="mx_SettingsTab_heading">{_t("Labs")}</div> <div className="mx_SettingsTab_heading">{_t("Labs")}</div>

View File

@ -124,6 +124,14 @@ export default class SettingsStore {
// Counter used for generation of watcher IDs // Counter used for generation of watcher IDs
private static watcherCount = 1; private static watcherCount = 1;
/**
* Gets all the feature-style setting names.
* @returns {string[]} The names of the feature settings.
*/
public static getFeatureSettingNames(): string[] {
return Object.keys(SETTINGS).filter(n => SettingsStore.isFeature(n));
}
/** /**
* Watches for changes in a particular setting. This is done without any local echo * Watches for changes in a particular setting. This is done without any local echo
* wrapping and fires whenever a change is detected in a setting's value, at any level. * wrapping and fires whenever a change is detected in a setting's value, at any level.