Show disabled spaces section in preferences regardless

This commit is contained in:
Michael Telatynski 2021-08-11 23:33:10 +01:00
parent 38dbe89316
commit 4f47907abf
4 changed files with 23 additions and 6 deletions

View file

@ -285,8 +285,16 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
SettingsStore.setValue("readMarkerOutOfViewThresholdMs", null, SettingLevel.DEVICE, e.target.value); SettingsStore.setValue("readMarkerOutOfViewThresholdMs", null, SettingLevel.DEVICE, e.target.value);
}; };
private renderGroup(settingIds: string[], level = SettingLevel.ACCOUNT): React.ReactNodeArray { private renderGroup(
return settingIds.filter(SettingsStore.isEnabled).map(i => { settingIds: string[],
level = SettingLevel.ACCOUNT,
includeDisabled = false,
): React.ReactNodeArray {
if (!includeDisabled) {
settingIds = settingIds.filter(SettingsStore.isEnabled);
}
return settingIds.map(i => {
return <SettingsFlag key={i} name={i} level={level} />; return <SettingsFlag key={i} name={i} level={level} />;
}); });
} }
@ -333,10 +341,10 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
{ this.renderGroup(PreferencesUserSettingsTab.ROOM_LIST_SETTINGS) } { this.renderGroup(PreferencesUserSettingsTab.ROOM_LIST_SETTINGS) }
</div> </div>
{ SpaceStore.spacesEnabled && <div className="mx_SettingsTab_section"> <div className="mx_SettingsTab_section">
<span className="mx_SettingsTab_subheading">{ _t("Spaces") }</span> <span className="mx_SettingsTab_subheading">{ _t("Spaces") }</span>
{ this.renderGroup(PreferencesUserSettingsTab.SPACES_SETTINGS) } { this.renderGroup(PreferencesUserSettingsTab.SPACES_SETTINGS, SettingLevel.ACCOUNT, true) }
</div> } </div>
<div className="mx_SettingsTab_section"> <div className="mx_SettingsTab_section">
<span className="mx_SettingsTab_subheading">{ _t("Communities") }</span> <span className="mx_SettingsTab_subheading">{ _t("Communities") }</span>

View file

@ -729,6 +729,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
description: _td("All rooms you're in will appear in Home."), description: _td("All rooms you're in will appear in Home."),
supportedLevels: LEVELS_ACCOUNT_SETTINGS, supportedLevels: LEVELS_ACCOUNT_SETTINGS,
default: false, default: false,
controller: new IncompatibleController("showCommunitiesInsteadOfSpaces", null),
}, },
"showCommunitiesInsteadOfSpaces": { "showCommunitiesInsteadOfSpaces": {
displayName: _td("Display Communities instead of Spaces"), displayName: _td("Display Communities instead of Spaces"),

View file

@ -467,6 +467,10 @@ export default class SettingsStore {
throw new Error("Setting '" + settingName + "' does not appear to be a setting."); throw new Error("Setting '" + settingName + "' does not appear to be a setting.");
} }
if (!SettingsStore.isEnabled(settingName)) {
return false;
}
// When non-beta features are specified in the config.json, we force them as enabled or disabled. // When non-beta features are specified in the config.json, we force them as enabled or disabled.
if (SettingsStore.isFeature(settingName) && !SETTINGS[settingName]?.betaInfo) { if (SettingsStore.isFeature(settingName) && !SETTINGS[settingName]?.betaInfo) {
const configVal = SettingsStore.getValueAt(SettingLevel.CONFIG, settingName, roomId, true, true); const configVal = SettingsStore.getValueAt(SettingLevel.CONFIG, settingName, roomId, true, true);

View file

@ -26,7 +26,7 @@ import SettingsStore from "../SettingsStore";
export default class IncompatibleController extends SettingController { export default class IncompatibleController extends SettingController {
public constructor( public constructor(
private settingName: string, private settingName: string,
private forcedValue = false, private forcedValue: any = false,
private incompatibleValue: any = true, private incompatibleValue: any = true,
) { ) {
super(); super();
@ -44,6 +44,10 @@ export default class IncompatibleController extends SettingController {
return null; // no override return null; // no override
} }
public get settingDisabled(): boolean {
return this.incompatibleSetting;
}
public get incompatibleSetting(): boolean { public get incompatibleSetting(): boolean {
return SettingsStore.getValue(this.settingName) === this.incompatibleValue; return SettingsStore.getValue(this.settingName) === this.incompatibleValue;
} }