From eda4e24926c00138db2fbbea850ce90b3875560b Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 17 Aug 2020 13:19:15 -0600 Subject: [PATCH] Update LabsUserSettings for new feature behaviour --- .../views/settings/tabs/user/LabsUserSettingsTab.js | 4 ++-- src/settings/SettingsStore.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/tabs/user/LabsUserSettingsTab.js b/src/components/views/settings/tabs/user/LabsUserSettingsTab.js index 2666671a30..6559448dfe 100644 --- a/src/components/views/settings/tabs/user/LabsUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/LabsUserSettingsTab.js @@ -28,7 +28,7 @@ export class LabsSettingToggle extends React.Component { }; _onChange = async (checked) => { - await SettingsStore.setFeatureEnabled(this.props.featureId, checked); + await SettingsStore.setValue(this.props.featureId, null, SettingLevel.DEVICE, checked); this.forceUpdate(); }; @@ -46,7 +46,7 @@ export default class LabsUserSettingsTab extends React.Component { render() { const SettingsFlag = sdk.getComponent("views.elements.SettingsFlag"); - const flags = SettingsStore.getLabsFeatures().map(f => ); + const flags = SettingsStore.getFeatureSettingNames().map(f => ); return (
{_t("Labs")}
diff --git a/src/settings/SettingsStore.ts b/src/settings/SettingsStore.ts index 6c1f9b8411..ea7d965720 100644 --- a/src/settings/SettingsStore.ts +++ b/src/settings/SettingsStore.ts @@ -124,6 +124,14 @@ export default class SettingsStore { // Counter used for generation of watcher IDs 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 * wrapping and fires whenever a change is detected in a setting's value, at any level.