Merge branch 'develop' into expand-codeblock
This commit is contained in:
commit
8a4af2f348
23 changed files with 382 additions and 172 deletions
|
@ -426,7 +426,8 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
default: true,
|
||||
},
|
||||
"allowedWidgets": {
|
||||
supportedLevels: [SettingLevel.ROOM_ACCOUNT],
|
||||
supportedLevels: [SettingLevel.ROOM_ACCOUNT, SettingLevel.ROOM_DEVICE],
|
||||
supportedLevelsAreOrdered: true,
|
||||
default: {}, // none allowed
|
||||
},
|
||||
"analyticsOptIn": {
|
||||
|
|
|
@ -467,6 +467,32 @@ export default class SettingsStore {
|
|||
return LEVEL_HANDLERS[level].isSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the first supported level out of all the levels that can be used for a
|
||||
* specific setting.
|
||||
* @param {string} settingName The setting name.
|
||||
* @return {SettingLevel}
|
||||
*/
|
||||
public static firstSupportedLevel(settingName: string): SettingLevel {
|
||||
// Verify that the setting is actually a setting
|
||||
const setting = SETTINGS[settingName];
|
||||
if (!setting) {
|
||||
throw new Error("Setting '" + settingName + "' does not appear to be a setting.");
|
||||
}
|
||||
|
||||
const levelOrder = (setting.supportedLevelsAreOrdered ? setting.supportedLevels : LEVEL_ORDER);
|
||||
if (!levelOrder.includes(SettingLevel.DEFAULT)) levelOrder.push(SettingLevel.DEFAULT); // always include default
|
||||
|
||||
const handlers = SettingsStore.getHandlers(settingName);
|
||||
|
||||
for (const level of levelOrder) {
|
||||
const handler = handlers[level];
|
||||
if (!handler) continue;
|
||||
return level;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Debugging function for reading explicit setting values without going through the
|
||||
* complicated/biased functions in the SettingsStore. This will print information to
|
||||
|
|
|
@ -169,7 +169,7 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
|
|||
|
||||
public isSupported(): boolean {
|
||||
const cli = MatrixClientPeg.get();
|
||||
return cli !== undefined && cli !== null;
|
||||
return cli !== undefined && cli !== null && !cli.isGuest();
|
||||
}
|
||||
|
||||
private getSettings(eventType = "im.vector.web.settings"): any { // TODO: [TS] Types on return
|
||||
|
|
|
@ -129,7 +129,7 @@ export default class RoomAccountSettingsHandler extends MatrixClientBackedSettin
|
|||
|
||||
public isSupported(): boolean {
|
||||
const cli = MatrixClientPeg.get();
|
||||
return cli !== undefined && cli !== null;
|
||||
return cli !== undefined && cli !== null && !cli.isGuest();
|
||||
}
|
||||
|
||||
private getSettings(roomId: string, eventType = "im.vector.web.settings"): any { // TODO: [TS] Type return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue