Merge branch 'develop' into feature-surround-with

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-02-12 07:56:44 +01:00
commit 8eb0707bba
No known key found for this signature in database
GPG key ID: 9760693FDD98A790
227 changed files with 17274 additions and 6142 deletions

View file

@ -240,6 +240,11 @@ export const SETTINGS: {[setting: string]: ISetting} = {
default: true,
invertedSettingName: 'MessageComposerInput.dontSuggestEmoji',
},
"MessageComposerInput.showStickersButton": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: _td('Show stickers button'),
default: true,
},
// TODO: Wire up appropriately to UI (FTUE notifications)
"Notifications.alwaysShowBadgeCounts": {
supportedLevels: LEVELS_ROOM_OR_ACCOUNT,
@ -300,6 +305,16 @@ export const SETTINGS: {[setting: string]: ISetting} = {
displayName: _td('Enable automatic language detection for syntax highlighting'),
default: false,
},
"expandCodeByDefault": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: _td('Expand code blocks by default'),
default: false,
},
"showCodeLineNumbers": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: _td('Show line numbers in code blocks'),
default: true,
},
"Pill.shouldShowPillAvatar": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: _td('Show avatars in user and room mentions'),
@ -331,6 +346,11 @@ export const SETTINGS: {[setting: string]: ISetting} = {
displayName: _td("Show typing notifications"),
default: true,
},
"ctrlFForSearch": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: isMac ? _td("Use Command + F to search") : _td("Use Ctrl + F to search"),
default: false,
},
"MessageComposerInput.ctrlEnterToSend": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: isMac ? _td("Use Command + Enter to send a message") : _td("Use Ctrl + Enter to send a message"),
@ -426,7 +446,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": {
@ -637,7 +658,11 @@ export const SETTINGS: {[setting: string]: ISetting} = {
displayName: _td("Show chat effects"),
default: true,
},
"Widgets.pinned": {
"Widgets.pinned": { // deprecated
supportedLevels: LEVELS_ROOM_OR_ACCOUNT,
default: {},
},
"Widgets.layout": {
supportedLevels: LEVELS_ROOM_OR_ACCOUNT,
default: {},
},

View file

@ -276,7 +276,7 @@ export default class SettingsStore {
* @param {boolean} excludeDefault True to disable using the default value.
* @return {*} The value, or null if not found
*/
public static getValue(settingName: string, roomId: string = null, excludeDefault = false): any {
public static getValue<T = any>(settingName: string, roomId: string = null, excludeDefault = false): T {
// Verify that the setting is actually a setting
if (!SETTINGS[settingName]) {
throw new Error("Setting '" + settingName + "' does not appear to be a setting.");
@ -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

View file

@ -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

View file

@ -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