diff --git a/src/settings/SettingsStore.ts b/src/settings/SettingsStore.ts index ea7d965720..dd75f8d1c9 100644 --- a/src/settings/SettingsStore.ts +++ b/src/settings/SettingsStore.ts @@ -53,7 +53,7 @@ const LEVEL_HANDLERS = { [SettingLevel.ROOM_ACCOUNT]: new RoomAccountSettingsHandler(defaultWatchManager), [SettingLevel.ACCOUNT]: new AccountSettingsHandler(defaultWatchManager), [SettingLevel.ROOM]: new RoomSettingsHandler(defaultWatchManager), - [SettingLevel.CONFIG]: new ConfigSettingsHandler(), + [SettingLevel.CONFIG]: new ConfigSettingsHandler(featureNames), [SettingLevel.DEFAULT]: new DefaultSettingsHandler(defaultSettings, invertedDefaultSettings), }; diff --git a/src/settings/handlers/ConfigSettingsHandler.ts b/src/settings/handlers/ConfigSettingsHandler.ts index 3e8b1724c1..791c655a0d 100644 --- a/src/settings/handlers/ConfigSettingsHandler.ts +++ b/src/settings/handlers/ConfigSettingsHandler.ts @@ -24,9 +24,24 @@ import {isNullOrUndefined} from "matrix-js-sdk/src/utils"; * roomId parameter. */ export default class ConfigSettingsHandler extends SettingsHandler { + public constructor(private featureNames: string[]) { + super(); + } + public getValue(settingName: string, roomId: string): any { const config = SdkConfig.get() || {}; + if (this.featureNames.includes(settingName)) { + const labsConfig = config["features"] || {}; + const val = labsConfig[settingName]; + if (isNullOrUndefined(val)) return null; // no definition at this level + if (val === true || val === false) return val; // new style: mapped as a boolean + if (val === "enable") return true; // backwards compat + if (val === "disable") return false; // backwards compat + if (val === "labs") return null; // backwards compat, no override + return null; // fallback in the case of invalid input + } + // Special case themes if (settingName === "theme") { return config["default_theme"];