diff --git a/src/components/views/elements/LanguageDropdown.js b/src/components/views/elements/LanguageDropdown.js index f6e63ca6f5..82fa9b869e 100644 --- a/src/components/views/elements/LanguageDropdown.js +++ b/src/components/views/elements/LanguageDropdown.js @@ -55,8 +55,7 @@ export default class LanguageDropdown extends React.Component { // If no value is given, we start with the first // country selected, but our parent component // doesn't know this, therefore we do this. - // TODO: {Travis} Ensure the default is *not* used for this check. It should try and use the browser. - const language = SettingsStore.getValue("language"); + const language = SettingsStore.getValue("language", null, /*excludeDefault:*/true); if (language) { this.props.onOptionChange(language); }else { @@ -97,8 +96,7 @@ export default class LanguageDropdown extends React.Component { // default value here too, otherwise we need to handle null / undefined // values between mounting and the initial value propgating - // TODO: {Travis} Ensure the default is *not* used for this check. It should try and use the browser. - let language = SettingsStore.getValue("language"); + let language = SettingsStore.getValue("language", null, /*excludeDefault:*/true); let value = null; if (language) { value = this.props.value || language; diff --git a/src/settings/SettingsStore.js b/src/settings/SettingsStore.js index d2b3c35a59..e74280b844 100644 --- a/src/settings/SettingsStore.js +++ b/src/settings/SettingsStore.js @@ -164,10 +164,11 @@ export default class SettingsStore { * be applied to any particular room, otherwise it should be supplied. * @param {string} settingName The name of the setting to read the value of. * @param {String} roomId The room ID to read the setting value in, may be null. + * @param {boolean} excludeDefault True to disable using the default value. * @return {*} The value, or null if not found */ - static getValue(settingName, roomId = null) { - return SettingsStore.getValueAt(LEVEL_ORDER[0], settingName, roomId); + static getValue(settingName, roomId = null, excludeDefault = false) { + return SettingsStore.getValueAt(LEVEL_ORDER[0], settingName, roomId, false, excludeDefault); } /** @@ -178,9 +179,10 @@ export default class SettingsStore { * @param {String} roomId The room ID to read the setting value in, may be null. * @param {boolean} explicit If true, this method will not consider other levels, just the one * provided. Defaults to false. + * @param {boolean} excludeDefault True to disable using the default value. * @return {*} The value, or null if not found. */ - static getValueAt(level, settingName, roomId = null, explicit = false) { + static getValueAt(level, settingName, roomId = null, explicit = false, excludeDefault = false) { const minIndex = LEVEL_ORDER.indexOf(level); if (minIndex === -1) throw new Error("Level " + level + " is not prioritized"); @@ -207,6 +209,7 @@ export default class SettingsStore { for (let i = minIndex; i < LEVEL_ORDER.length; i++) { let handler = handlers[LEVEL_ORDER[i]]; if (!handler) continue; + if (excludeDefault && LEVEL_ORDER[i] === "default") continue; const value = handler.getValue(settingName, roomId); if (value === null || value === undefined) continue;