Merge branch 'develop' into gsouquet/message-bubbles-4635

This commit is contained in:
Germain Souquet 2021-06-30 08:58:05 +01:00
commit d9eec1c03b
767 changed files with 11330 additions and 9146 deletions

View file

@ -1,6 +1,6 @@
/*
Copyright 2017 Travis Ralston
Copyright 2018, 2019, 2020 The Matrix.org Foundation C.I.C.
Copyright 2018 - 2021 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -95,6 +95,9 @@ export interface ISetting {
[level: SettingLevel]: string;
};
// Optional description which will be shown as microCopy under SettingsFlags
description?: string;
// The supported levels are required. Preferably, use the preset arrays
// at the top of this file to define this rather than a custom array.
supportedLevels?: SettingLevel[];
@ -128,10 +131,18 @@ export interface ISetting {
image: string; // require(...)
feedbackSubheading?: string;
feedbackLabel?: string;
extraSettings?: string[];
};
}
export const SETTINGS: {[setting: string]: ISetting} = {
"feature_report_to_moderators": {
isFeature: true,
displayName: _td("Report to moderators prototype. " +
"In rooms that support moderation, the `report` button will let you report abuse to room moderators"),
supportedLevels: LEVELS_FEATURE,
default: false,
},
"feature_spaces": {
isFeature: true,
displayName: _td("Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags. " +
@ -168,8 +179,33 @@ export const SETTINGS: {[setting: string]: ISetting} = {
feedbackSubheading: _td("Your feedback will help make spaces better. " +
"The more detail you can go into, the better."),
feedbackLabel: "spaces-feedback",
extraSettings: [
"feature_spaces.all_rooms",
"feature_spaces.space_member_dms",
"feature_spaces.space_dm_badges",
],
},
},
"feature_spaces.all_rooms": {
displayName: _td("Show all rooms in Home"),
supportedLevels: LEVELS_FEATURE,
default: true,
controller: new ReloadOnChangeController(),
},
"feature_spaces.space_member_dms": {
displayName: _td("Show people in spaces"),
description: _td("If disabled, you can still add Direct Messages to Personal Spaces. " +
"If enabled, you'll automatically see everyone who is a member of the Space."),
supportedLevels: LEVELS_FEATURE,
default: true,
controller: new ReloadOnChangeController(),
},
"feature_spaces.space_dm_badges": {
displayName: _td("Show notification badges for People in Spaces"),
supportedLevels: LEVELS_FEATURE,
default: false,
controller: new ReloadOnChangeController(),
},
"feature_dnd": {
isFeature: true,
displayName: _td("Show options to enable 'Do not disturb' mode"),
@ -578,14 +614,6 @@ export const SETTINGS: {[setting: string]: ISetting} = {
default: false,
controller: new UIFeatureController(UIFeature.URLPreviews),
},
"roomColor": {
supportedLevels: LEVELS_ROOM_SETTINGS_WITH_ROOM,
displayName: _td("Room Colour"),
default: {
primary_color: null, // Hex string, eg: #000000
secondary_color: null, // Hex string, eg: #000000
},
},
"notificationsEnabled": {
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
default: false,

View file

@ -248,6 +248,16 @@ export default class SettingsStore {
return _t(displayName as string);
}
/**
* Gets the translated description for a given setting
* @param {string} settingName The setting to look up.
* @return {String} The description for the setting, or null if not found.
*/
public static getDescription(settingName: string) {
if (!SETTINGS[settingName]?.description) return null;
return _t(SETTINGS[settingName].description);
}
/**
* Determines if a setting is also a feature.
* @param {string} settingName The setting to look up.

View file

@ -16,11 +16,11 @@ limitations under the License.
*/
import SettingController from "./SettingController";
import {MatrixClientPeg} from '../../MatrixClientPeg';
import { MatrixClientPeg } from '../../MatrixClientPeg';
import { SettingLevel } from "../SettingLevel";
// XXX: This feels wrong.
import {PushProcessor} from "matrix-js-sdk/src/pushprocessor";
import { PushProcessor } from "matrix-js-sdk/src/pushprocessor";
// .m.rule.master being enabled means all events match that push rule
// default action on this rule is dont_notify, but it could be something else

View file

@ -16,7 +16,7 @@ limitations under the License.
*/
import SettingController from "./SettingController";
import {DEFAULT_THEME, enumerateThemes} from "../../theme";
import { DEFAULT_THEME, enumerateThemes } from "../../theme";
import { SettingLevel } from "../SettingLevel";
export default class ThemeController extends SettingController {

View file

@ -15,10 +15,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {MatrixClientPeg} from '../../MatrixClientPeg';
import { MatrixClientPeg } from '../../MatrixClientPeg';
import MatrixClientBackedSettingsHandler from "./MatrixClientBackedSettingsHandler";
import {objectClone, objectKeyChanges} from "../../utils/objects";
import {SettingLevel} from "../SettingLevel";
import { objectClone, objectKeyChanges } from "../../utils/objects";
import { SettingLevel } from "../SettingLevel";
import { WatchManager } from "../WatchManager";
import { MatrixClient } from "matrix-js-sdk/src/client";
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
@ -73,7 +73,7 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
const val = event.getContent()['enabled'];
this.watchers.notifyUpdate("recent_emoji", null, SettingLevel.ACCOUNT, val);
}
}
};
public getValue(settingName: string, roomId: string): any {
// Special case URL previews

View file

@ -17,7 +17,7 @@ limitations under the License.
import SettingsHandler from "./SettingsHandler";
import SdkConfig from "../../SdkConfig";
import {isNullOrUndefined} from "matrix-js-sdk/src/utils";
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
/**
* Gets and sets settings at the "config" level. This handler does not make use of the

View file

@ -17,8 +17,8 @@ limitations under the License.
*/
import SettingsHandler from "./SettingsHandler";
import {MatrixClientPeg} from "../../MatrixClientPeg";
import {SettingLevel} from "../SettingLevel";
import { MatrixClientPeg } from "../../MatrixClientPeg";
import { SettingLevel } from "../SettingLevel";
import { CallbackFn, WatchManager } from "../WatchManager";
import { Layout } from "../Layout";
@ -109,7 +109,7 @@ export default class DeviceSettingsHandler extends SettingsHandler {
"lastRightPanelPhaseForRoom",
"lastRightPanelPhaseForGroup",
].includes(settingName)) {
localStorage.setItem(`mx_${settingName}`, JSON.stringify({value: newValue}));
localStorage.setItem(`mx_${settingName}`, JSON.stringify({ value: newValue }));
this.watchers.notifyUpdate(settingName, null, SettingLevel.DEVICE, newValue);
return Promise.resolve();
}

View file

@ -54,8 +54,6 @@ export default class RoomAccountSettingsHandler extends MatrixClientBackedSettin
}
this.watchers.notifyUpdate("urlPreviewsEnabled", roomId, SettingLevel.ROOM_ACCOUNT, val);
} else if (event.getType() === "org.matrix.room.color_scheme") {
this.watchers.notifyUpdate("roomColor", roomId, SettingLevel.ROOM_ACCOUNT, event.getContent());
} else if (event.getType() === "im.vector.web.settings") {
// Figure out what changed and fire those updates
const prevContent = prevEvent ? prevEvent.getContent() : {};
@ -79,14 +77,6 @@ export default class RoomAccountSettingsHandler extends MatrixClientBackedSettin
return !content['disable'];
}
// Special case room color
if (settingName === "roomColor") {
// The event content should already be in an appropriate format, we just need
// to get the right value.
// don't fallback to {} because thats truthy and would imply there is an event specifying tint
return this.getSettings(roomId, "org.matrix.room.color_scheme");
}
// Special case allowed widgets
if (settingName === "allowedWidgets") {
return this.getSettings(roomId, ALLOWED_WIDGETS_EVENT_TYPE);
@ -104,12 +94,6 @@ export default class RoomAccountSettingsHandler extends MatrixClientBackedSettin
return MatrixClientPeg.get().setRoomAccountData(roomId, "org.matrix.room.preview_urls", content);
}
// Special case room color
if (settingName === "roomColor") {
// The new value should match our requirements, we just need to store it in the right place.
return MatrixClientPeg.get().setRoomAccountData(roomId, "org.matrix.room.color_scheme", newValue);
}
// Special case allowed widgets
if (settingName === "allowedWidgets") {
return MatrixClientPeg.get().setRoomAccountData(roomId, ALLOWED_WIDGETS_EVENT_TYPE, newValue);

View file

@ -57,7 +57,7 @@ export default class RoomDeviceSettingsHandler extends SettingsHandler {
if (newValue === null) {
localStorage.removeItem(this.getKey(settingName, roomId));
} else {
newValue = JSON.stringify({value: newValue});
newValue = JSON.stringify({ value: newValue });
localStorage.setItem(this.getKey(settingName, roomId), newValue);
}

View file

@ -63,7 +63,7 @@ export class FontWatcher implements IWatcher {
(<HTMLElement>document.querySelector(":root")).style.fontSize = toPx(fontSize);
};
private setSystemFont = ({useSystemFont, font}) => {
private setSystemFont = ({ useSystemFont, font }) => {
document.body.style.fontFamily = useSystemFont ? font : "";
};
}