Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -15,34 +15,34 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { MatrixClient } from 'matrix-js-sdk/src/client';
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import React, { ReactNode } from "react";
|
||||
|
||||
import { _t, _td } from '../languageHandler';
|
||||
import { _t, _td } from "../languageHandler";
|
||||
import {
|
||||
NotificationBodyEnabledController,
|
||||
NotificationsEnabledController,
|
||||
} from "./controllers/NotificationControllers";
|
||||
import ThemeController from './controllers/ThemeController';
|
||||
import PushToMatrixClientController from './controllers/PushToMatrixClientController';
|
||||
import ThemeController from "./controllers/ThemeController";
|
||||
import PushToMatrixClientController from "./controllers/PushToMatrixClientController";
|
||||
import ReloadOnChangeController from "./controllers/ReloadOnChangeController";
|
||||
import FontSizeController from './controllers/FontSizeController';
|
||||
import SystemFontController from './controllers/SystemFontController';
|
||||
import UseSystemFontController from './controllers/UseSystemFontController';
|
||||
import FontSizeController from "./controllers/FontSizeController";
|
||||
import SystemFontController from "./controllers/SystemFontController";
|
||||
import UseSystemFontController from "./controllers/UseSystemFontController";
|
||||
import { SettingLevel } from "./SettingLevel";
|
||||
import SettingController from "./controllers/SettingController";
|
||||
import { IS_MAC } from '../Keyboard';
|
||||
import { IS_MAC } from "../Keyboard";
|
||||
import UIFeatureController from "./controllers/UIFeatureController";
|
||||
import { UIFeature } from "./UIFeature";
|
||||
import { OrderedMultiController } from "./controllers/OrderedMultiController";
|
||||
import { Layout } from "./enums/Layout";
|
||||
import ReducedMotionController from './controllers/ReducedMotionController';
|
||||
import ReducedMotionController from "./controllers/ReducedMotionController";
|
||||
import IncompatibleController from "./controllers/IncompatibleController";
|
||||
import { ImageSize } from "./enums/ImageSize";
|
||||
import { MetaSpace } from "../stores/spaces";
|
||||
import SdkConfig from "../SdkConfig";
|
||||
import SlidingSyncController from './controllers/SlidingSyncController';
|
||||
import ThreadBetaController from './controllers/ThreadBetaController';
|
||||
import SlidingSyncController from "./controllers/SlidingSyncController";
|
||||
import ThreadBetaController from "./controllers/ThreadBetaController";
|
||||
import { FontWatcher } from "./watchers/FontWatcher";
|
||||
|
||||
// These are just a bunch of helper arrays to avoid copy/pasting a bunch of times
|
||||
|
@ -53,10 +53,7 @@ const LEVELS_ROOM_SETTINGS = [
|
|||
SettingLevel.ACCOUNT,
|
||||
SettingLevel.CONFIG,
|
||||
];
|
||||
const LEVELS_ROOM_OR_ACCOUNT = [
|
||||
SettingLevel.ROOM_ACCOUNT,
|
||||
SettingLevel.ACCOUNT,
|
||||
];
|
||||
const LEVELS_ROOM_OR_ACCOUNT = [SettingLevel.ROOM_ACCOUNT, SettingLevel.ACCOUNT];
|
||||
const LEVELS_ROOM_SETTINGS_WITH_ROOM = [
|
||||
SettingLevel.DEVICE,
|
||||
SettingLevel.ROOM_DEVICE,
|
||||
|
@ -65,22 +62,10 @@ const LEVELS_ROOM_SETTINGS_WITH_ROOM = [
|
|||
SettingLevel.CONFIG,
|
||||
SettingLevel.ROOM,
|
||||
];
|
||||
const LEVELS_ACCOUNT_SETTINGS = [
|
||||
SettingLevel.DEVICE,
|
||||
SettingLevel.ACCOUNT,
|
||||
SettingLevel.CONFIG,
|
||||
];
|
||||
const LEVELS_FEATURE = [
|
||||
SettingLevel.DEVICE,
|
||||
SettingLevel.CONFIG,
|
||||
];
|
||||
const LEVELS_DEVICE_ONLY_SETTINGS = [
|
||||
SettingLevel.DEVICE,
|
||||
];
|
||||
const LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG = [
|
||||
SettingLevel.DEVICE,
|
||||
SettingLevel.CONFIG,
|
||||
];
|
||||
const LEVELS_ACCOUNT_SETTINGS = [SettingLevel.DEVICE, SettingLevel.ACCOUNT, SettingLevel.CONFIG];
|
||||
const LEVELS_FEATURE = [SettingLevel.DEVICE, SettingLevel.CONFIG];
|
||||
const LEVELS_DEVICE_ONLY_SETTINGS = [SettingLevel.DEVICE];
|
||||
const LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG = [SettingLevel.DEVICE, SettingLevel.CONFIG];
|
||||
const LEVELS_UI_FEATURE = [
|
||||
SettingLevel.CONFIG,
|
||||
// in future we might have a .well-known level or something
|
||||
|
@ -122,23 +107,19 @@ export const labGroupNames: Record<LabGroup, string> = {
|
|||
[LabGroup.Developer]: _td("Developer"),
|
||||
};
|
||||
|
||||
export type SettingValueType = boolean
|
||||
| number
|
||||
| string
|
||||
| number[]
|
||||
| string[]
|
||||
| Record<string, unknown>
|
||||
| null;
|
||||
export type SettingValueType = boolean | number | string | number[] | string[] | Record<string, unknown> | null;
|
||||
|
||||
export interface IBaseSetting<T extends SettingValueType = SettingValueType> {
|
||||
isFeature?: false | undefined;
|
||||
|
||||
// Display names are strongly recommended for clarity.
|
||||
// Display name can also be an object for different levels.
|
||||
displayName?: string | {
|
||||
// @ts-ignore - TS wants the key to be a string, but we know better
|
||||
[level: SettingLevel]: string;
|
||||
};
|
||||
displayName?:
|
||||
| string
|
||||
| {
|
||||
// @ts-ignore - TS wants the key to be a string, but we know better
|
||||
[level: SettingLevel]: string;
|
||||
};
|
||||
|
||||
// Optional description which will be shown as microCopy under SettingsFlags
|
||||
description?: string | (() => ReactNode);
|
||||
|
@ -194,7 +175,7 @@ export interface IFeature extends Omit<IBaseSetting<boolean>, "isFeature"> {
|
|||
// Type using I-identifier for backwards compatibility from before it became a discriminated union
|
||||
export type ISetting = IBaseSetting | IFeature;
|
||||
|
||||
export const SETTINGS: {[setting: string]: ISetting} = {
|
||||
export const SETTINGS: { [setting: string]: ISetting } = {
|
||||
"feature_video_rooms": {
|
||||
isFeature: true,
|
||||
labsGroup: LabGroup.VoiceAndVideo,
|
||||
|
@ -205,28 +186,33 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
controller: new ReloadOnChangeController(),
|
||||
betaInfo: {
|
||||
title: _td("Video rooms"),
|
||||
caption: () => <>
|
||||
<p>
|
||||
{ _t("A new way to chat over voice and video in %(brand)s.", {
|
||||
brand: SdkConfig.get().brand,
|
||||
}) }
|
||||
</p>
|
||||
<p>
|
||||
{ _t("Video rooms are always-on VoIP channels embedded within a room in %(brand)s.", {
|
||||
brand: SdkConfig.get().brand,
|
||||
}) }
|
||||
</p>
|
||||
</>,
|
||||
caption: () => (
|
||||
<>
|
||||
<p>
|
||||
{_t("A new way to chat over voice and video in %(brand)s.", {
|
||||
brand: SdkConfig.get().brand,
|
||||
})}
|
||||
</p>
|
||||
<p>
|
||||
{_t("Video rooms are always-on VoIP channels embedded within a room in %(brand)s.", {
|
||||
brand: SdkConfig.get().brand,
|
||||
})}
|
||||
</p>
|
||||
</>
|
||||
),
|
||||
faq: () =>
|
||||
SdkConfig.get().bug_report_endpoint_url && <>
|
||||
<h4>{ _t("How can I create a video room?") }</h4>
|
||||
<p>{ _t("Use the “+” button in the room section of the left panel.") }</p>
|
||||
<h4>{ _t("Can I use text chat alongside the video call?") }</h4>
|
||||
<p>{ _t("Yes, the chat timeline is displayed alongside the video.") }</p>
|
||||
</>,
|
||||
SdkConfig.get().bug_report_endpoint_url && (
|
||||
<>
|
||||
<h4>{_t("How can I create a video room?")}</h4>
|
||||
<p>{_t("Use the “+” button in the room section of the left panel.")}</p>
|
||||
<h4>{_t("Can I use text chat alongside the video call?")}</h4>
|
||||
<p>{_t("Yes, the chat timeline is displayed alongside the video.")}</p>
|
||||
</>
|
||||
),
|
||||
feedbackLabel: "video-room-feedback",
|
||||
feedbackSubheading: _td("Thank you for trying the beta, " +
|
||||
"please go into as much detail as you can so we can improve it."),
|
||||
feedbackSubheading: _td(
|
||||
"Thank you for trying the beta, " + "please go into as much detail as you can so we can improve it.",
|
||||
),
|
||||
image: require("../../res/img/betas/video_rooms.png"),
|
||||
requiresRefresh: true,
|
||||
},
|
||||
|
@ -250,8 +236,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
labsGroup: LabGroup.Moderation,
|
||||
displayName: _td("Report to moderators"),
|
||||
description: _td(
|
||||
"In rooms that support moderation, "
|
||||
+"the “Report” button will let you report abuse to room moderators.",
|
||||
"In rooms that support moderation, " + "the “Report” button will let you report abuse to room moderators.",
|
||||
),
|
||||
supportedLevels: LEVELS_FEATURE,
|
||||
default: false,
|
||||
|
@ -279,36 +264,48 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
default: false,
|
||||
betaInfo: {
|
||||
title: _td("Threads"),
|
||||
caption: () => <>
|
||||
<p>{ _t("Keep discussions organised with threads.") }</p>
|
||||
<p>{ _t("Threads help keep conversations on-topic and easy to track. <a>Learn more</a>.", {}, {
|
||||
a: (sub) => <a href="https://element.io/help#threads" rel="noreferrer noopener" target="_blank">
|
||||
{ sub }
|
||||
</a>,
|
||||
}) }</p>
|
||||
</>,
|
||||
caption: () => (
|
||||
<>
|
||||
<p>{_t("Keep discussions organised with threads.")}</p>
|
||||
<p>
|
||||
{_t(
|
||||
"Threads help keep conversations on-topic and easy to track. <a>Learn more</a>.",
|
||||
{},
|
||||
{
|
||||
a: (sub) => (
|
||||
<a href="https://element.io/help#threads" rel="noreferrer noopener" target="_blank">
|
||||
{sub}
|
||||
</a>
|
||||
),
|
||||
},
|
||||
)}
|
||||
</p>
|
||||
</>
|
||||
),
|
||||
faq: () =>
|
||||
SdkConfig.get().bug_report_endpoint_url && <>
|
||||
<h4>{ _t("How can I start a thread?") }</h4>
|
||||
<p>
|
||||
{ _t("Use “%(replyInThread)s” when hovering over a message.", {
|
||||
replyInThread: _t("Reply in thread"),
|
||||
}) }
|
||||
</p>
|
||||
<h4>{ _t("How can I leave the beta?") }</h4>
|
||||
<p>
|
||||
{ _t("To leave, return to this page and use the “%(leaveTheBeta)s” button.", {
|
||||
leaveTheBeta: _t("Leave the beta"),
|
||||
}) }
|
||||
</p>
|
||||
</>,
|
||||
SdkConfig.get().bug_report_endpoint_url && (
|
||||
<>
|
||||
<h4>{_t("How can I start a thread?")}</h4>
|
||||
<p>
|
||||
{_t("Use “%(replyInThread)s” when hovering over a message.", {
|
||||
replyInThread: _t("Reply in thread"),
|
||||
})}
|
||||
</p>
|
||||
<h4>{_t("How can I leave the beta?")}</h4>
|
||||
<p>
|
||||
{_t("To leave, return to this page and use the “%(leaveTheBeta)s” button.", {
|
||||
leaveTheBeta: _t("Leave the beta"),
|
||||
})}
|
||||
</p>
|
||||
</>
|
||||
),
|
||||
feedbackLabel: "thread-feedback",
|
||||
feedbackSubheading: _td("Thank you for trying the beta, " +
|
||||
"please go into as much detail as you can so we can improve it."),
|
||||
feedbackSubheading: _td(
|
||||
"Thank you for trying the beta, " + "please go into as much detail as you can so we can improve it.",
|
||||
),
|
||||
image: require("../../res/img/betas/threads.png"),
|
||||
requiresRefresh: true,
|
||||
},
|
||||
|
||||
},
|
||||
"feature_wysiwyg_composer": {
|
||||
isFeature: true,
|
||||
|
@ -434,7 +431,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
isFeature: true,
|
||||
labsGroup: LabGroup.Developer,
|
||||
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG,
|
||||
displayName: _td('Sliding Sync mode'),
|
||||
displayName: _td("Sliding Sync mode"),
|
||||
description: _td("Under active development, cannot be disabled."),
|
||||
shouldWarn: true,
|
||||
default: false,
|
||||
|
@ -492,20 +489,18 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
displayName: _td("Use new session manager"),
|
||||
default: false,
|
||||
betaInfo: {
|
||||
title: _td('New session manager'),
|
||||
caption: () => <>
|
||||
<p>
|
||||
{ _td('Have greater visibility and control over all your sessions.') }
|
||||
</p>
|
||||
<p>
|
||||
{ _td(
|
||||
'Our new sessions manager provides better visibility of all your sessions, '
|
||||
+ 'and greater control over them including the ability to remotely toggle push notifications.',
|
||||
)
|
||||
}
|
||||
</p>
|
||||
|
||||
</>,
|
||||
title: _td("New session manager"),
|
||||
caption: () => (
|
||||
<>
|
||||
<p>{_td("Have greater visibility and control over all your sessions.")}</p>
|
||||
<p>
|
||||
{_td(
|
||||
"Our new sessions manager provides better visibility of all your sessions, " +
|
||||
"and greater control over them including the ability to remotely toggle push notifications.",
|
||||
)}
|
||||
</p>
|
||||
</>
|
||||
),
|
||||
},
|
||||
},
|
||||
"feature_qr_signin_reciprocate_show": {
|
||||
|
@ -514,7 +509,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
supportedLevels: LEVELS_FEATURE,
|
||||
displayName: _td(
|
||||
"Allow a QR code to be shown in session manager to sign in another device " +
|
||||
"(requires compatible homeserver)",
|
||||
"(requires compatible homeserver)",
|
||||
),
|
||||
default: false,
|
||||
},
|
||||
|
@ -531,24 +526,24 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
},
|
||||
"MessageComposerInput.suggestEmoji": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Enable Emoji suggestions while typing'),
|
||||
displayName: _td("Enable Emoji suggestions while typing"),
|
||||
default: true,
|
||||
invertedSettingName: 'MessageComposerInput.dontSuggestEmoji',
|
||||
invertedSettingName: "MessageComposerInput.dontSuggestEmoji",
|
||||
},
|
||||
"MessageComposerInput.showStickersButton": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Show stickers button'),
|
||||
displayName: _td("Show stickers button"),
|
||||
default: true,
|
||||
controller: new UIFeatureController(UIFeature.Widgets, false),
|
||||
},
|
||||
"MessageComposerInput.showPollsButton": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Show polls button'),
|
||||
displayName: _td("Show polls button"),
|
||||
default: true,
|
||||
},
|
||||
"MessageComposerInput.insertTrailingColon": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Insert a trailing colon after user mentions at the start of a message'),
|
||||
displayName: _td("Insert a trailing colon after user mentions at the start of a message"),
|
||||
default: true,
|
||||
},
|
||||
// TODO: Wire up appropriately to UI (FTUE notifications)
|
||||
|
@ -571,85 +566,85 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
},
|
||||
"showRedactions": {
|
||||
supportedLevels: LEVELS_ROOM_SETTINGS_WITH_ROOM,
|
||||
displayName: _td('Show a placeholder for removed messages'),
|
||||
displayName: _td("Show a placeholder for removed messages"),
|
||||
default: true,
|
||||
invertedSettingName: 'hideRedactions',
|
||||
invertedSettingName: "hideRedactions",
|
||||
},
|
||||
"showJoinLeaves": {
|
||||
supportedLevels: LEVELS_ROOM_SETTINGS_WITH_ROOM,
|
||||
displayName: _td('Show join/leave messages (invites/removes/bans unaffected)'),
|
||||
displayName: _td("Show join/leave messages (invites/removes/bans unaffected)"),
|
||||
default: true,
|
||||
invertedSettingName: 'hideJoinLeaves',
|
||||
invertedSettingName: "hideJoinLeaves",
|
||||
},
|
||||
"showAvatarChanges": {
|
||||
supportedLevels: LEVELS_ROOM_SETTINGS_WITH_ROOM,
|
||||
displayName: _td('Show avatar changes'),
|
||||
displayName: _td("Show avatar changes"),
|
||||
default: true,
|
||||
invertedSettingName: 'hideAvatarChanges',
|
||||
invertedSettingName: "hideAvatarChanges",
|
||||
},
|
||||
"showDisplaynameChanges": {
|
||||
supportedLevels: LEVELS_ROOM_SETTINGS_WITH_ROOM,
|
||||
displayName: _td('Show display name changes'),
|
||||
displayName: _td("Show display name changes"),
|
||||
default: true,
|
||||
invertedSettingName: 'hideDisplaynameChanges',
|
||||
invertedSettingName: "hideDisplaynameChanges",
|
||||
},
|
||||
"showReadReceipts": {
|
||||
supportedLevels: LEVELS_ROOM_SETTINGS,
|
||||
displayName: _td('Show read receipts sent by other users'),
|
||||
displayName: _td("Show read receipts sent by other users"),
|
||||
default: true,
|
||||
invertedSettingName: 'hideReadReceipts',
|
||||
invertedSettingName: "hideReadReceipts",
|
||||
},
|
||||
"showTwelveHourTimestamps": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Show timestamps in 12 hour format (e.g. 2:30pm)'),
|
||||
displayName: _td("Show timestamps in 12 hour format (e.g. 2:30pm)"),
|
||||
default: false,
|
||||
},
|
||||
"alwaysShowTimestamps": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Always show message timestamps'),
|
||||
displayName: _td("Always show message timestamps"),
|
||||
default: false,
|
||||
},
|
||||
"autoplayGifs": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Autoplay GIFs'),
|
||||
displayName: _td("Autoplay GIFs"),
|
||||
default: false,
|
||||
},
|
||||
"autoplayVideo": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Autoplay videos'),
|
||||
displayName: _td("Autoplay videos"),
|
||||
default: false,
|
||||
},
|
||||
"enableSyntaxHighlightLanguageDetection": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Enable automatic language detection for syntax highlighting'),
|
||||
displayName: _td("Enable automatic language detection for syntax highlighting"),
|
||||
default: false,
|
||||
},
|
||||
"expandCodeByDefault": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Expand code blocks by default'),
|
||||
displayName: _td("Expand code blocks by default"),
|
||||
default: false,
|
||||
},
|
||||
"showCodeLineNumbers": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Show line numbers in code blocks'),
|
||||
displayName: _td("Show line numbers in code blocks"),
|
||||
default: true,
|
||||
},
|
||||
"scrollToBottomOnMessageSent": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Jump to the bottom of the timeline when you send a message'),
|
||||
displayName: _td("Jump to the bottom of the timeline when you send a message"),
|
||||
default: true,
|
||||
},
|
||||
"Pill.shouldShowPillAvatar": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Show avatars in user and room mentions'),
|
||||
displayName: _td("Show avatars in user and room mentions"),
|
||||
default: true,
|
||||
invertedSettingName: 'Pill.shouldHidePillAvatar',
|
||||
invertedSettingName: "Pill.shouldHidePillAvatar",
|
||||
},
|
||||
"TextualBody.enableBigEmoji": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Enable big emoji in chat'),
|
||||
displayName: _td("Enable big emoji in chat"),
|
||||
default: true,
|
||||
invertedSettingName: 'TextualBody.disableBigEmoji',
|
||||
invertedSettingName: "TextualBody.disableBigEmoji",
|
||||
},
|
||||
"MessageComposerInput.isRichTextEnabled": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
|
@ -663,7 +658,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td("Send typing notifications"),
|
||||
default: true,
|
||||
invertedSettingName: 'dontSendTypingNotifications',
|
||||
invertedSettingName: "dontSendTypingNotifications",
|
||||
},
|
||||
"showTypingNotifications": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
|
@ -687,22 +682,23 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
},
|
||||
"MessageComposerInput.autoReplaceEmoji": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Automatically replace plain text Emoji'),
|
||||
displayName: _td("Automatically replace plain text Emoji"),
|
||||
default: false,
|
||||
},
|
||||
"MessageComposerInput.useMarkdown": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Enable Markdown'),
|
||||
description: () => _t(
|
||||
"Start messages with <code>/plain</code> to send without markdown and <code>/md</code> to send with.",
|
||||
{},
|
||||
{ code: (sub) => <code>{ sub }</code> },
|
||||
),
|
||||
displayName: _td("Enable Markdown"),
|
||||
description: () =>
|
||||
_t(
|
||||
"Start messages with <code>/plain</code> to send without markdown and <code>/md</code> to send with.",
|
||||
{},
|
||||
{ code: (sub) => <code>{sub}</code> },
|
||||
),
|
||||
default: true,
|
||||
},
|
||||
"VideoView.flipVideoHorizontally": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Mirror local video feed'),
|
||||
displayName: _td("Mirror local video feed"),
|
||||
default: false,
|
||||
},
|
||||
"theme": {
|
||||
|
@ -736,7 +732,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
displayName: _td("Allow Peer-to-Peer for 1:1 calls"),
|
||||
description: _td("When enabled, the other party might be able to see your IP address"),
|
||||
default: true,
|
||||
invertedSettingName: 'webRtcForceTURN',
|
||||
invertedSettingName: "webRtcForceTURN",
|
||||
},
|
||||
"webrtc_audiooutput": {
|
||||
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
|
||||
|
@ -804,14 +800,13 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
},
|
||||
"pseudonymousAnalyticsOptIn": {
|
||||
supportedLevels: [SettingLevel.ACCOUNT],
|
||||
displayName: _td('Send analytics data'),
|
||||
displayName: _td("Send analytics data"),
|
||||
default: null,
|
||||
},
|
||||
"deviceClientInformationOptIn": {
|
||||
supportedLevels: [SettingLevel.ACCOUNT],
|
||||
displayName: _td(
|
||||
`Record the client name, version, and url ` +
|
||||
`to recognise sessions more easily in session manager`,
|
||||
`Record the client name, version, and url ` + `to recognise sessions more easily in session manager`,
|
||||
),
|
||||
default: false,
|
||||
},
|
||||
|
@ -837,8 +832,8 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
supportedLevels: [SettingLevel.ROOM_DEVICE, SettingLevel.DEVICE],
|
||||
supportedLevelsAreOrdered: true,
|
||||
displayName: {
|
||||
"default": _td('Never send encrypted messages to unverified sessions from this session'),
|
||||
"room-device": _td('Never send encrypted messages to unverified sessions in this room from this session'),
|
||||
"default": _td("Never send encrypted messages to unverified sessions from this session"),
|
||||
"room-device": _td("Never send encrypted messages to unverified sessions in this room from this session"),
|
||||
},
|
||||
default: false,
|
||||
controller: new UIFeatureController(UIFeature.AdvancedEncryption),
|
||||
|
@ -846,7 +841,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
"urlPreviewsEnabled": {
|
||||
supportedLevels: LEVELS_ROOM_SETTINGS_WITH_ROOM,
|
||||
displayName: {
|
||||
"default": _td('Enable inline URL previews by default'),
|
||||
"default": _td("Enable inline URL previews by default"),
|
||||
"room-account": _td("Enable URL previews for this room (only affects you)"),
|
||||
"room": _td("Enable URL previews by default for participants in this room"),
|
||||
},
|
||||
|
@ -885,12 +880,12 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
},
|
||||
"enableWidgetScreenshots": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Enable widget screenshots on supported widgets'),
|
||||
displayName: _td("Enable widget screenshots on supported widgets"),
|
||||
default: false,
|
||||
},
|
||||
"promptBeforeInviteUnknownUsers": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Prompt before sending invites to potentially invalid matrix IDs'),
|
||||
displayName: _td("Prompt before sending invites to potentially invalid matrix IDs"),
|
||||
default: true,
|
||||
},
|
||||
"widgetOpenIDPermissions": {
|
||||
|
@ -930,7 +925,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
},
|
||||
"lowBandwidth": {
|
||||
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG,
|
||||
displayName: _td('Low bandwidth mode'),
|
||||
displayName: _td("Low bandwidth mode"),
|
||||
description: _td("Requires compatible homeserver."),
|
||||
default: false,
|
||||
controller: new ReloadOnChangeController(),
|
||||
|
@ -940,8 +935,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
|
||||
displayName: _td("Allow fallback call assist server (turn.matrix.org)"),
|
||||
description: _td(
|
||||
"Only applies if your homeserver does not offer one. " +
|
||||
"Your IP address would be shared during a call.",
|
||||
"Only applies if your homeserver does not offer one. " + "Your IP address would be shared during a call.",
|
||||
),
|
||||
// This is a tri-state value, where `null` means "prompt the user".
|
||||
default: null,
|
||||
|
@ -985,9 +979,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
// show up and can't be toggled. PushToMatrixClientController doesn't
|
||||
// do any overrides anyways.
|
||||
new UIFeatureController(UIFeature.AdvancedEncryption),
|
||||
new PushToMatrixClientController(
|
||||
MatrixClient.prototype.setCryptoTrustCrossSignedDevices, true,
|
||||
),
|
||||
new PushToMatrixClientController(MatrixClient.prototype.setCryptoTrustCrossSignedDevices, true),
|
||||
]),
|
||||
},
|
||||
"ircDisplayNameWidth": {
|
||||
|
@ -1016,7 +1008,8 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
supportedLevels: [SettingLevel.CONFIG],
|
||||
default: false,
|
||||
},
|
||||
"Widgets.pinned": { // deprecated
|
||||
"Widgets.pinned": {
|
||||
// deprecated
|
||||
supportedLevels: LEVELS_ROOM_OR_ACCOUNT,
|
||||
default: {},
|
||||
},
|
||||
|
|
|
@ -25,8 +25,8 @@ import RoomAccountSettingsHandler from "./handlers/RoomAccountSettingsHandler";
|
|||
import AccountSettingsHandler from "./handlers/AccountSettingsHandler";
|
||||
import RoomSettingsHandler from "./handlers/RoomSettingsHandler";
|
||||
import ConfigSettingsHandler from "./handlers/ConfigSettingsHandler";
|
||||
import { _t } from '../languageHandler';
|
||||
import dis from '../dispatcher/dispatcher';
|
||||
import { _t } from "../languageHandler";
|
||||
import dis from "../dispatcher/dispatcher";
|
||||
import { IFeature, ISetting, LabGroup, SETTINGS } from "./Settings";
|
||||
import LocalEchoWrapper from "./handlers/LocalEchoWrapper";
|
||||
import { CallbackFn as WatchCallbackFn, WatchManager } from "./WatchManager";
|
||||
|
@ -144,7 +144,7 @@ export default class SettingsStore {
|
|||
* @returns {string[]} The names of the feature settings.
|
||||
*/
|
||||
public static getFeatureSettingNames(): string[] {
|
||||
return Object.keys(SETTINGS).filter(n => SettingsStore.isFeature(n));
|
||||
return Object.keys(SETTINGS).filter((n) => SettingsStore.isFeature(n));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,8 +178,8 @@ export default class SettingsStore {
|
|||
if (!SettingsStore.doesSettingSupportLevel(originalSettingName, atLevel)) {
|
||||
logger.warn(
|
||||
`Setting handler notified for an update of an invalid setting level: ` +
|
||||
`${originalSettingName}@${atLevel} - this likely means a weird setting value ` +
|
||||
`made it into the level's storage. The notification will be ignored.`,
|
||||
`${originalSettingName}@${atLevel} - this likely means a weird setting value ` +
|
||||
`made it into the level's storage. The notification will be ignored.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -224,18 +224,23 @@ export default class SettingsStore {
|
|||
if (!this.monitors.has(settingName)) this.monitors.set(settingName, new Map());
|
||||
|
||||
const registerWatcher = () => {
|
||||
this.monitors.get(settingName).set(roomId, SettingsStore.watchSetting(
|
||||
settingName, roomId, (settingName, inRoomId, level, newValueAtLevel, newValue) => {
|
||||
dis.dispatch<SettingUpdatedPayload>({
|
||||
action: Action.SettingUpdated,
|
||||
settingName,
|
||||
roomId: inRoomId,
|
||||
level,
|
||||
newValueAtLevel,
|
||||
newValue,
|
||||
});
|
||||
},
|
||||
));
|
||||
this.monitors.get(settingName).set(
|
||||
roomId,
|
||||
SettingsStore.watchSetting(
|
||||
settingName,
|
||||
roomId,
|
||||
(settingName, inRoomId, level, newValueAtLevel, newValue) => {
|
||||
dis.dispatch<SettingUpdatedPayload>({
|
||||
action: Action.SettingUpdated,
|
||||
settingName,
|
||||
roomId: inRoomId,
|
||||
level,
|
||||
newValueAtLevel,
|
||||
newValue,
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
const rooms = Array.from(this.monitors.get(settingName).keys());
|
||||
|
@ -245,7 +250,7 @@ export default class SettingsStore {
|
|||
} else {
|
||||
if (roomId === null) {
|
||||
// Unregister all existing watchers and register the new one
|
||||
rooms.forEach(roomId => {
|
||||
rooms.forEach((roomId) => {
|
||||
SettingsStore.unwatchSetting(this.monitors.get(settingName).get(roomId));
|
||||
});
|
||||
this.monitors.get(settingName).clear();
|
||||
|
@ -281,7 +286,7 @@ export default class SettingsStore {
|
|||
public static getDescription(settingName: string): string | ReactNode {
|
||||
const description = SETTINGS[settingName]?.description;
|
||||
if (!description) return null;
|
||||
if (typeof description !== 'string') return description();
|
||||
if (typeof description !== "string") return description();
|
||||
return _t(description);
|
||||
}
|
||||
|
||||
|
@ -307,8 +312,9 @@ export default class SettingsStore {
|
|||
|
||||
public static getBetaInfo(settingName: string): ISetting["betaInfo"] {
|
||||
// consider a beta disabled if the config is explicitly set to false, in which case treat as normal Labs flag
|
||||
if (SettingsStore.isFeature(settingName)
|
||||
&& SettingsStore.getValueAt(SettingLevel.CONFIG, settingName, null, true, true) !== false
|
||||
if (
|
||||
SettingsStore.isFeature(settingName) &&
|
||||
SettingsStore.getValueAt(SettingLevel.CONFIG, settingName, null, true, true) !== false
|
||||
) {
|
||||
return SETTINGS[settingName]?.betaInfo;
|
||||
}
|
||||
|
@ -554,7 +560,7 @@ export default class SettingsStore {
|
|||
throw new Error("Setting '" + settingName + "' does not appear to be a setting.");
|
||||
}
|
||||
|
||||
return level === SettingLevel.DEFAULT || (setting.supportedLevels.includes(level));
|
||||
return level === SettingLevel.DEFAULT || setting.supportedLevels.includes(level);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -636,7 +642,7 @@ export default class SettingsStore {
|
|||
// to show up in a rageshake if required.
|
||||
|
||||
const def = SETTINGS[realSettingName];
|
||||
logger.log(`--- definition: ${def ? JSON.stringify(def) : '<NOT_FOUND>'}`);
|
||||
logger.log(`--- definition: ${def ? JSON.stringify(def) : "<NOT_FOUND>"}`);
|
||||
logger.log(`--- default level order: ${JSON.stringify(LEVEL_ORDER)}`);
|
||||
logger.log(`--- registered handlers: ${JSON.stringify(Object.keys(LEVEL_HANDLERS))}`);
|
||||
|
||||
|
@ -646,9 +652,9 @@ export default class SettingsStore {
|
|||
|
||||
try {
|
||||
const value = handler.getValue(settingName, roomId);
|
||||
logger.log(`--- ${handlerName}@${roomId || '<no_room>'} = ${JSON.stringify(value)}`);
|
||||
logger.log(`--- ${handlerName}@${roomId || "<no_room>"} = ${JSON.stringify(value)}`);
|
||||
} catch (e) {
|
||||
logger.log(`--- ${handler}@${roomId || '<no_room>'} THREW ERROR: ${e.message}`);
|
||||
logger.log(`--- ${handler}@${roomId || "<no_room>"} THREW ERROR: ${e.message}`);
|
||||
logger.error(e);
|
||||
}
|
||||
|
||||
|
@ -668,9 +674,9 @@ export default class SettingsStore {
|
|||
|
||||
try {
|
||||
const value = SettingsStore.getValue(settingName, roomId);
|
||||
logger.log(`--- SettingsStore#generic@${roomId || '<no_room>'} = ${JSON.stringify(value)}`);
|
||||
logger.log(`--- SettingsStore#generic@${roomId || "<no_room>"} = ${JSON.stringify(value)}`);
|
||||
} catch (e) {
|
||||
logger.log(`--- SettingsStore#generic@${roomId || '<no_room>'} THREW ERROR: ${e.message}`);
|
||||
logger.log(`--- SettingsStore#generic@${roomId || "<no_room>"} THREW ERROR: ${e.message}`);
|
||||
logger.error(e);
|
||||
}
|
||||
|
||||
|
@ -687,9 +693,9 @@ export default class SettingsStore {
|
|||
for (const level of LEVEL_ORDER) {
|
||||
try {
|
||||
const value = SettingsStore.getValueAt(level, settingName, roomId);
|
||||
logger.log(`--- SettingsStore#${level}@${roomId || '<no_room>'} = ${JSON.stringify(value)}`);
|
||||
logger.log(`--- SettingsStore#${level}@${roomId || "<no_room>"} = ${JSON.stringify(value)}`);
|
||||
} catch (e) {
|
||||
logger.log(`--- SettingsStore#${level}@${roomId || '<no_room>'} THREW ERROR: ${e.message}`);
|
||||
logger.log(`--- SettingsStore#${level}@${roomId || "<no_room>"} THREW ERROR: ${e.message}`);
|
||||
logger.error(e);
|
||||
}
|
||||
|
||||
|
@ -732,7 +738,7 @@ export default class SettingsStore {
|
|||
}
|
||||
|
||||
// Always support 'default'
|
||||
if (!handlers['default']) handlers['default'] = LEVEL_HANDLERS['default'];
|
||||
if (!handlers["default"]) handlers["default"] = LEVEL_HANDLERS["default"];
|
||||
|
||||
return handlers;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import { PushProcessor } from "matrix-js-sdk/src/pushprocessor";
|
|||
import { PushRuleActionName } from "matrix-js-sdk/src/@types/PushRules";
|
||||
|
||||
import SettingController from "./SettingController";
|
||||
import { MatrixClientPeg } from '../../MatrixClientPeg';
|
||||
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||
import { SettingLevel } from "../SettingLevel";
|
||||
|
||||
// .m.rule.master being enabled means all events match that push rule
|
||||
|
@ -40,9 +40,10 @@ export function isPushNotifyDisabled(): boolean {
|
|||
return masterRule.enabled && !masterRule.actions.includes(PushRuleActionName.Notify);
|
||||
}
|
||||
|
||||
function getNotifier(): any { // TODO: [TS] Formal type that doesn't cause a cyclical reference.
|
||||
function getNotifier(): any {
|
||||
// TODO: [TS] Formal type that doesn't cause a cyclical reference.
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
let Notifier = require('../../Notifier'); // avoids cyclical references
|
||||
let Notifier = require("../../Notifier"); // avoids cyclical references
|
||||
if (Notifier.default) Notifier = Notifier.default; // correct for webpack require() weirdness
|
||||
return Notifier;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { MatrixClientPeg } from '../../MatrixClientPeg';
|
||||
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||
import { SettingLevel } from "../SettingLevel";
|
||||
import SettingController from "./SettingController";
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ export default class ThemeController extends SettingController {
|
|||
): any {
|
||||
if (!calculatedValue) return null; // Don't override null themes
|
||||
|
||||
if (ThemeController.isLogin) return 'light';
|
||||
if (ThemeController.isLogin) return "light";
|
||||
|
||||
const themes = enumerateThemes();
|
||||
// Override in case some no longer supported theme is stored here
|
||||
|
|
|
@ -30,15 +30,25 @@ export default class ThreadBetaController extends SettingController {
|
|||
|
||||
const { finished } = Modal.createDialog<[boolean]>(QuestionDialog, {
|
||||
title: _t("Partial Support for Threads"),
|
||||
description: <>
|
||||
<p>{ _t("Your homeserver does not currently support threads, so this feature may be unreliable. " +
|
||||
"Some threaded messages may not be reliably available. <a>Learn more</a>.", {}, {
|
||||
a: sub => (
|
||||
<a href="https://element.io/help#threads" target="_blank" rel="noreferrer noopener">{ sub }</a>
|
||||
),
|
||||
}) }</p>
|
||||
<p>{ _t("Do you want to enable threads anyway?") }</p>
|
||||
</>,
|
||||
description: (
|
||||
<>
|
||||
<p>
|
||||
{_t(
|
||||
"Your homeserver does not currently support threads, so this feature may be unreliable. " +
|
||||
"Some threaded messages may not be reliably available. <a>Learn more</a>.",
|
||||
{},
|
||||
{
|
||||
a: (sub) => (
|
||||
<a href="https://element.io/help#threads" target="_blank" rel="noreferrer noopener">
|
||||
{sub}
|
||||
</a>
|
||||
),
|
||||
},
|
||||
)}
|
||||
</p>
|
||||
<p>{_t("Do you want to enable threads anyway?")}</p>
|
||||
</>
|
||||
),
|
||||
button: _t("Yes, enable"),
|
||||
});
|
||||
const [enable] = await finished;
|
||||
|
|
|
@ -20,9 +20,9 @@ const SIZE_LARGE = { w: 800, h: 600 };
|
|||
// For Normal the image gets drawn to never exceed SIZE_NORMAL.w, SIZE_NORMAL.h
|
||||
// constraint by: timeline width, manual height overrides
|
||||
const SIZE_NORMAL_LANDSCAPE = { w: 324, h: 324 }; // for w > h
|
||||
const SIZE_NORMAL_PORTRAIT = { w: Math.ceil(324 * (9/16)), h: 324 }; // for h > w
|
||||
const SIZE_NORMAL_PORTRAIT = { w: Math.ceil(324 * (9 / 16)), h: 324 }; // for h > w
|
||||
|
||||
type Dimensions = { w: number, h: number };
|
||||
type Dimensions = { w: number; h: number };
|
||||
|
||||
export enum ImageSize {
|
||||
Normal = "normal",
|
||||
|
@ -39,8 +39,7 @@ export function suggestedSize(size: ImageSize, contentSize: Dimensions, maxHeigh
|
|||
const aspectRatio = contentSize.w / contentSize.h;
|
||||
const portrait = aspectRatio < 1;
|
||||
|
||||
const maxSize = (size === ImageSize.Large) ? SIZE_LARGE :
|
||||
portrait ? SIZE_NORMAL_PORTRAIT : SIZE_NORMAL_LANDSCAPE;
|
||||
const maxSize = size === ImageSize.Large ? SIZE_LARGE : portrait ? SIZE_NORMAL_PORTRAIT : SIZE_NORMAL_LANDSCAPE;
|
||||
if (!contentSize.w || !contentSize.h) {
|
||||
return maxSize;
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
|
|||
|
||||
private onAccountData = (event: MatrixEvent, prevEvent: MatrixEvent) => {
|
||||
if (event.getType() === "org.matrix.preview_urls") {
|
||||
let val = event.getContent()['disable'];
|
||||
if (typeof(val) !== "boolean") {
|
||||
let val = event.getContent()["disable"];
|
||||
if (typeof val !== "boolean") {
|
||||
val = null;
|
||||
} else {
|
||||
val = !val;
|
||||
|
@ -71,10 +71,10 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
|
|||
} else if (BREADCRUMBS_EVENT_TYPES.includes(event.getType())) {
|
||||
this.notifyBreadcrumbsUpdate(event);
|
||||
} else if (event.getType() === INTEG_PROVISIONING_EVENT_TYPE) {
|
||||
const val = event.getContent()['enabled'];
|
||||
const val = event.getContent()["enabled"];
|
||||
this.watchers.notifyUpdate("integrationProvisioning", null, SettingLevel.ACCOUNT, val);
|
||||
} else if (event.getType() === RECENT_EMOJI_EVENT_TYPE) {
|
||||
const val = event.getContent()['enabled'];
|
||||
const val = event.getContent()["enabled"];
|
||||
this.watchers.notifyUpdate("recent_emoji", null, SettingLevel.ACCOUNT, val);
|
||||
}
|
||||
};
|
||||
|
@ -85,21 +85,21 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
|
|||
const content = this.getSettings("org.matrix.preview_urls") || {};
|
||||
|
||||
// Check to make sure that we actually got a boolean
|
||||
if (typeof(content['disable']) !== "boolean") return null;
|
||||
return !content['disable'];
|
||||
if (typeof content["disable"] !== "boolean") return null;
|
||||
return !content["disable"];
|
||||
}
|
||||
|
||||
// Special case for breadcrumbs
|
||||
if (settingName === "breadcrumb_rooms") {
|
||||
let content = this.getSettings(BREADCRUMBS_EVENT_TYPE);
|
||||
if (!content || !content['recent_rooms']) {
|
||||
if (!content || !content["recent_rooms"]) {
|
||||
content = this.getSettings(BREADCRUMBS_LEGACY_EVENT_TYPE);
|
||||
|
||||
// This is a bit of a hack, but it makes things slightly easier
|
||||
if (content) content['recent_rooms'] = content['rooms'];
|
||||
if (content) content["recent_rooms"] = content["rooms"];
|
||||
}
|
||||
|
||||
return content && content['recent_rooms'] ? content['recent_rooms'] : [];
|
||||
return content && content["recent_rooms"] ? content["recent_rooms"] : [];
|
||||
}
|
||||
|
||||
// Special case recent emoji
|
||||
|
@ -111,13 +111,13 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
|
|||
// Special case integration manager provisioning
|
||||
if (settingName === "integrationProvisioning") {
|
||||
const content = this.getSettings(INTEG_PROVISIONING_EVENT_TYPE);
|
||||
return content ? content['enabled'] : null;
|
||||
return content ? content["enabled"] : null;
|
||||
}
|
||||
|
||||
if (settingName === "pseudonymousAnalyticsOptIn") {
|
||||
const content = this.getSettings(ANALYTICS_EVENT_TYPE) || {};
|
||||
// Check to make sure that we actually got a boolean
|
||||
if (typeof(content[settingName]) !== "boolean") return null;
|
||||
if (typeof content[settingName] !== "boolean") return null;
|
||||
return content[settingName];
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,8 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
|
|||
return this.client && !this.client.isGuest();
|
||||
}
|
||||
|
||||
private getSettings(eventType = "im.vector.web.settings"): any { // TODO: [TS] Types on return
|
||||
private getSettings(eventType = "im.vector.web.settings"): any {
|
||||
// TODO: [TS] Types on return
|
||||
if (!this.client) return null;
|
||||
|
||||
const event = this.client.getAccountData(eventType);
|
||||
|
@ -233,10 +234,10 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
|
|||
if (event.getType() === BREADCRUMBS_LEGACY_EVENT_TYPE) {
|
||||
// This seems fishy - try and get the event for the new rooms
|
||||
const newType = this.getSettings(BREADCRUMBS_EVENT_TYPE);
|
||||
if (newType) val = newType['recent_rooms'];
|
||||
else val = event.getContent()['rooms'];
|
||||
if (newType) val = newType["recent_rooms"];
|
||||
else val = event.getContent()["rooms"];
|
||||
} else if (event.getType() === BREADCRUMBS_EVENT_TYPE) {
|
||||
val = event.getContent()['recent_rooms'];
|
||||
val = event.getContent()["recent_rooms"];
|
||||
} else {
|
||||
return; // for sanity, not because we expect to be here.
|
||||
}
|
||||
|
|
|
@ -107,7 +107,8 @@ export default class DeviceSettingsHandler extends AbstractLocalStorageSettingsH
|
|||
this.watchers.unwatchSetting(cb);
|
||||
}
|
||||
|
||||
private getSettings(): any { // TODO: [TS] Type return
|
||||
private getSettings(): any {
|
||||
// TODO: [TS] Type return
|
||||
return this.getObject("mx_local_settings");
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ export default class PlatformSettingsHandler extends SettingsHandler {
|
|||
// Load setting values as they are async and `getValue` must be synchronous
|
||||
Object.entries(SETTINGS).forEach(([key, setting]) => {
|
||||
if (setting.supportedLevels.includes(SettingLevel.PLATFORM) && payload.platform.supportsSetting(key)) {
|
||||
payload.platform.getSettingValue(key).then(value => {
|
||||
payload.platform.getSettingValue(key).then((value) => {
|
||||
this.store[key] = value;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ export default class RoomAccountSettingsHandler extends MatrixClientBackedSettin
|
|||
const roomId = room.roomId;
|
||||
|
||||
if (event.getType() === "org.matrix.room.preview_urls") {
|
||||
let val = event.getContent()['disable'];
|
||||
if (typeof (val) !== "boolean") {
|
||||
let val = event.getContent()["disable"];
|
||||
if (typeof val !== "boolean") {
|
||||
val = null;
|
||||
} else {
|
||||
val = !val;
|
||||
|
@ -75,8 +75,8 @@ export default class RoomAccountSettingsHandler extends MatrixClientBackedSettin
|
|||
const content = this.getSettings(roomId, "org.matrix.room.preview_urls") || {};
|
||||
|
||||
// Check to make sure that we actually got a boolean
|
||||
if (typeof (content['disable']) !== "boolean") return null;
|
||||
return !content['disable'];
|
||||
if (typeof content["disable"] !== "boolean") return null;
|
||||
return !content["disable"];
|
||||
}
|
||||
|
||||
// Special case allowed widgets
|
||||
|
@ -142,7 +142,8 @@ export default class RoomAccountSettingsHandler extends MatrixClientBackedSettin
|
|||
return this.client && !this.client.isGuest();
|
||||
}
|
||||
|
||||
private getSettings(roomId: string, eventType = DEFAULT_SETTINGS_EVENT_TYPE): any { // TODO: [TS] Type return
|
||||
private getSettings(roomId: string, eventType = DEFAULT_SETTINGS_EVENT_TYPE): any {
|
||||
// TODO: [TS] Type return
|
||||
const event = this.client.getRoom(roomId)?.getAccountData(eventType);
|
||||
if (!event || !event.getContent()) return null;
|
||||
return objectClone(event.getContent()); // clone to prevent mutation
|
||||
|
|
|
@ -32,8 +32,8 @@ export default class RoomDeviceSettingsHandler extends AbstractLocalStorageSetti
|
|||
// Special case blacklist setting to use legacy values
|
||||
if (settingName === "blacklistUnverifiedDevices") {
|
||||
const value = this.read("mx_local_settings");
|
||||
if (value?.['blacklistUnverifiedDevicesPerRoom']) {
|
||||
return value['blacklistUnverifiedDevicesPerRoom'][roomId];
|
||||
if (value?.["blacklistUnverifiedDevicesPerRoom"]) {
|
||||
return value["blacklistUnverifiedDevicesPerRoom"][roomId];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ export default class RoomSettingsHandler extends MatrixClientBackedSettingsHandl
|
|||
if (room && state !== room.currentState) return;
|
||||
|
||||
if (event.getType() === "org.matrix.room.preview_urls") {
|
||||
let val = event.getContent()['disable'];
|
||||
if (typeof (val) !== "boolean") {
|
||||
let val = event.getContent()["disable"];
|
||||
if (typeof val !== "boolean") {
|
||||
val = null;
|
||||
} else {
|
||||
val = !val;
|
||||
|
@ -81,8 +81,8 @@ export default class RoomSettingsHandler extends MatrixClientBackedSettingsHandl
|
|||
const content = this.getSettings(roomId, "org.matrix.room.preview_urls") || {};
|
||||
|
||||
// Check to make sure that we actually got a boolean
|
||||
if (typeof (content['disable']) !== "boolean") return null;
|
||||
return !content['disable'];
|
||||
if (typeof content["disable"] !== "boolean") return null;
|
||||
return !content["disable"];
|
||||
}
|
||||
|
||||
const settings = this.getSettings(roomId) || {};
|
||||
|
@ -90,12 +90,7 @@ export default class RoomSettingsHandler extends MatrixClientBackedSettingsHandl
|
|||
}
|
||||
|
||||
// helper function to send state event then await it being echoed back
|
||||
private async sendStateEvent(
|
||||
roomId: string,
|
||||
eventType: string,
|
||||
field: string,
|
||||
value: any,
|
||||
): Promise<void> {
|
||||
private async sendStateEvent(roomId: string, eventType: string, field: string, value: any): Promise<void> {
|
||||
const content = this.getSettings(roomId, eventType) || {};
|
||||
content[field] = value;
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import dis from '../../dispatcher/dispatcher';
|
||||
import SettingsStore from '../SettingsStore';
|
||||
import dis from "../../dispatcher/dispatcher";
|
||||
import SettingsStore from "../SettingsStore";
|
||||
import IWatcher from "./Watcher";
|
||||
import { toPx } from '../../utils/units';
|
||||
import { Action } from '../../dispatcher/actions';
|
||||
import { toPx } from "../../utils/units";
|
||||
import { Action } from "../../dispatcher/actions";
|
||||
import { SettingLevel } from "../SettingLevel";
|
||||
import { UpdateSystemFontPayload } from "../../dispatcher/payloads/UpdateSystemFontPayload";
|
||||
import { ActionPayload } from "../../dispatcher/payloads";
|
||||
|
@ -84,15 +84,15 @@ export class FontWatcher implements IWatcher {
|
|||
if (useSystemFont) {
|
||||
// Make sure that fonts with spaces in their names get interpreted properly
|
||||
document.body.style.fontFamily = font
|
||||
.split(',')
|
||||
.map(font => {
|
||||
.split(",")
|
||||
.map((font) => {
|
||||
font = font.trim();
|
||||
if (!font.startsWith('"') && !font.endsWith('"')) {
|
||||
font = `"${font}"`;
|
||||
}
|
||||
return font;
|
||||
})
|
||||
.join(',');
|
||||
.join(",");
|
||||
} else {
|
||||
document.body.style.fontFamily = "";
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@ limitations under the License.
|
|||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import SettingsStore from '../SettingsStore';
|
||||
import dis from '../../dispatcher/dispatcher';
|
||||
import { Action } from '../../dispatcher/actions';
|
||||
import SettingsStore from "../SettingsStore";
|
||||
import dis from "../../dispatcher/dispatcher";
|
||||
import { Action } from "../../dispatcher/actions";
|
||||
import ThemeController from "../controllers/ThemeController";
|
||||
import { findHighContrastTheme, setTheme } from "../../theme";
|
||||
import { ActionPayload } from '../../dispatcher/payloads';
|
||||
import { ActionPayload } from "../../dispatcher/payloads";
|
||||
import { SettingLevel } from "../SettingLevel";
|
||||
|
||||
export default class ThemeWatcher {
|
||||
|
@ -54,18 +54,18 @@ export default class ThemeWatcher {
|
|||
this.themeWatchRef = SettingsStore.watchSetting("theme", null, this.onChange);
|
||||
this.systemThemeWatchRef = SettingsStore.watchSetting("use_system_theme", null, this.onChange);
|
||||
if (this.preferDark.addEventListener) {
|
||||
this.preferDark.addEventListener('change', this.onChange);
|
||||
this.preferLight.addEventListener('change', this.onChange);
|
||||
this.preferHighContrast.addEventListener('change', this.onChange);
|
||||
this.preferDark.addEventListener("change", this.onChange);
|
||||
this.preferLight.addEventListener("change", this.onChange);
|
||||
this.preferHighContrast.addEventListener("change", this.onChange);
|
||||
}
|
||||
this.dispatcherRef = dis.register(this.onAction);
|
||||
}
|
||||
|
||||
public stop() {
|
||||
if (this.preferDark.addEventListener) {
|
||||
this.preferDark.removeEventListener('change', this.onChange);
|
||||
this.preferLight.removeEventListener('change', this.onChange);
|
||||
this.preferHighContrast.removeEventListener('change', this.onChange);
|
||||
this.preferDark.removeEventListener("change", this.onChange);
|
||||
this.preferLight.removeEventListener("change", this.onChange);
|
||||
this.preferHighContrast.removeEventListener("change", this.onChange);
|
||||
}
|
||||
SettingsStore.unwatchSetting(this.systemThemeWatchRef);
|
||||
SettingsStore.unwatchSetting(this.themeWatchRef);
|
||||
|
@ -103,13 +103,18 @@ export default class ThemeWatcher {
|
|||
// controller that honours the same flag, although probably better would be to
|
||||
// have the theme logic in one place rather than split between however many
|
||||
// different places.
|
||||
if (ThemeController.isLogin) return 'light';
|
||||
if (ThemeController.isLogin) return "light";
|
||||
|
||||
// If the user has specifically enabled the system matching option (excluding default),
|
||||
// then use that over anything else. We pick the lowest possible level for the setting
|
||||
// to ensure the ordering otherwise works.
|
||||
const systemThemeExplicit = SettingsStore.getValueAt(
|
||||
SettingLevel.DEVICE, "use_system_theme", null, false, true);
|
||||
SettingLevel.DEVICE,
|
||||
"use_system_theme",
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
);
|
||||
if (systemThemeExplicit) {
|
||||
logger.log("returning explicit system theme");
|
||||
const theme = this.themeBasedOnSystem();
|
||||
|
@ -121,8 +126,7 @@ export default class ThemeWatcher {
|
|||
// If the user has specifically enabled the theme (without the system matching option being
|
||||
// enabled specifically and excluding the default), use that theme. We pick the lowest possible
|
||||
// level for the setting to ensure the ordering otherwise works.
|
||||
const themeExplicit = SettingsStore.getValueAt(
|
||||
SettingLevel.DEVICE, "theme", null, false, true);
|
||||
const themeExplicit = SettingsStore.getValueAt(SettingLevel.DEVICE, "theme", null, false, true);
|
||||
if (themeExplicit) {
|
||||
logger.log("returning explicit theme: " + themeExplicit);
|
||||
return themeExplicit;
|
||||
|
@ -130,22 +134,22 @@ export default class ThemeWatcher {
|
|||
|
||||
// If the user hasn't really made a preference in either direction, assume the defaults of the
|
||||
// settings and use those.
|
||||
if (SettingsStore.getValue('use_system_theme')) {
|
||||
if (SettingsStore.getValue("use_system_theme")) {
|
||||
const theme = this.themeBasedOnSystem();
|
||||
if (theme) {
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
logger.log("returning theme value");
|
||||
return SettingsStore.getValue('theme');
|
||||
return SettingsStore.getValue("theme");
|
||||
}
|
||||
|
||||
private themeBasedOnSystem() {
|
||||
let newTheme: string;
|
||||
if (this.preferDark.matches) {
|
||||
newTheme = 'dark';
|
||||
newTheme = "dark";
|
||||
} else if (this.preferLight.matches) {
|
||||
newTheme = 'light';
|
||||
newTheme = "light";
|
||||
}
|
||||
if (this.preferHighContrast.matches) {
|
||||
const hcTheme = findHighContrastTheme(newTheme);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue