Cut some import cycles (#34038)

* Fix SettingsController -> SettingsStore import cycles

* Fix AnalyticsToast<->AnalyticsLearnMoreDialog import cycle

* Fix emojipicker import cycle

* Fix MessageComposerButtons import cycle

* Fix ReadReceiptGroup<>ReadReceiptMarker import cycle

* Fix RoomSettingsDialog import cycles

* Fix SlashCommands import cycles

* Fix Pill import cycles

* Fill TODO comment
This commit is contained in:
Michael Telatynski
2026-06-30 12:49:28 +00:00
committed by GitHub
parent c33a159334
commit ffdd9595c7
44 changed files with 140 additions and 111 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ import { ALL_RULE_TYPES, ROOM_RULE_TYPES, SERVER_RULE_TYPES, USER_RULE_TYPES } f
import { WIDGET_LAYOUT_EVENT_TYPE } from "./stores/widgets/WidgetLayoutStore";
import { RightPanelPhases } from "./stores/right-panel/RightPanelStorePhases";
import defaultDispatcher from "./dispatcher/dispatcher";
import { RoomSettingsTab } from "./components/views/dialogs/RoomSettingsDialog";
import { RoomSettingsTab } from "./components/views/dialogs/RoomSettingsDialog-tab";
import AccessibleButton from "./components/views/elements/AccessibleButton";
import RightPanelStore from "./stores/right-panel/RightPanelStore";
import { highlightEvent, isLocationEvent } from "./utils/EventUtils";
@@ -14,9 +14,12 @@ import { _t } from "../../../languageHandler";
import DialogButtons from "../elements/DialogButtons";
import Modal, { type ComponentProps, type IHandle } from "../../../Modal";
import SdkConfig from "../../../SdkConfig";
import { getPolicyUrl } from "../../../toasts/AnalyticsToast";
import ExternalLink from "../elements/ExternalLink";
function getPolicyUrl(): string | undefined {
return SdkConfig.get("privacy_policy_url");
}
export enum ButtonClicked {
Primary,
Cancel,
@@ -0,0 +1,21 @@
/*
Copyright 2024 New Vector Ltd.
Copyright 2023 The Matrix.org Foundation C.I.C.
Copyright 2019 New Vector Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
export const enum RoomSettingsTab {
General = "ROOM_GENERAL_TAB",
People = "ROOM_PEOPLE_TAB",
Voip = "ROOM_VOIP_TAB",
Security = "ROOM_SECURITY_TAB",
Roles = "ROOM_ROLES_TAB",
Notifications = "ROOM_NOTIFICATIONS_TAB",
Bridges = "ROOM_BRIDGES_TAB",
Advanced = "ROOM_ADVANCED_TAB",
PollHistory = "ROOM_POLL_HISTORY_TAB",
}
@@ -43,18 +43,7 @@ import { PollHistoryTab } from "../settings/tabs/room/PollHistoryTab";
import ErrorBoundary from "../elements/ErrorBoundary";
import { PeopleRoomSettingsTab } from "../settings/tabs/room/PeopleRoomSettingsTab";
import { SDKContext, type SdkContextClass } from "../../../contexts/SDKContext";
export const enum RoomSettingsTab {
General = "ROOM_GENERAL_TAB",
People = "ROOM_PEOPLE_TAB",
Voip = "ROOM_VOIP_TAB",
Security = "ROOM_SECURITY_TAB",
Roles = "ROOM_ROLES_TAB",
Notifications = "ROOM_NOTIFICATIONS_TAB",
Bridges = "ROOM_BRIDGES_TAB",
Advanced = "ROOM_ADVANCED_TAB",
PollHistory = "ROOM_POLL_HISTORY_TAB",
}
import { RoomSettingsTab } from "./RoomSettingsDialog-tab.ts";
interface IProps {
roomId: string;
@@ -17,15 +17,7 @@ import { usePermalink } from "../../../hooks/usePermalink";
import RoomAvatar from "../avatars/RoomAvatar";
import MemberAvatar from "../avatars/MemberAvatar";
import { _t } from "../../../languageHandler";
export enum PillType {
UserMention = "TYPE_USER_MENTION",
RoomMention = "TYPE_ROOM_MENTION",
AtRoomMention = "TYPE_AT_ROOM_MENTION", // '@room' mention
EventInSameRoom = "TYPE_EVENT_IN_SAME_ROOM",
EventInOtherRoom = "TYPE_EVENT_IN_OTHER_ROOM",
Keyword = "TYPE_KEYWORD", // Used to highlight keywords that triggered a notification rule
}
import { PillType } from "./PillType";
const linkIcon = <LinkIcon className="mx_Pill_LinkIcon mx_BaseAvatar" />;
@@ -0,0 +1,16 @@
/*
Copyright 2024 New Vector Ltd.
Copyright 2017-2019 , 2021 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
export enum PillType {
UserMention = "TYPE_USER_MENTION",
RoomMention = "TYPE_ROOM_MENTION",
AtRoomMention = "TYPE_AT_ROOM_MENTION", // '@room' mention
EventInSameRoom = "TYPE_EVENT_IN_SAME_ROOM",
EventInOtherRoom = "TYPE_EVENT_IN_OTHER_ROOM",
Keyword = "TYPE_KEYWORD", // Used to highlight keywords that triggered a notification rule
}
@@ -19,7 +19,8 @@ import { getUserNameColorClass } from "../../../utils/FormattingUtils";
import { Action } from "../../../dispatcher/actions";
import Spinner from "./Spinner";
import ReplyTile from "../rooms/ReplyTile";
import { Pill, PillType } from "./Pill";
import { Pill } from "./Pill";
import { PillType } from "./PillType";
import AccessibleButton from "./AccessibleButton";
import { getParentEventId, shouldDisplayReply } from "../../../utils/Reply";
import RoomContext from "../../../contexts/RoomContext";
@@ -10,7 +10,7 @@ Please see LICENSE files in the repository root for full details.
import React, { type JSX, type RefObject } from "react";
import { type DATA_BY_CATEGORY, type Emoji as IEmoji } from "@matrix-org/emojibase-bindings";
import { CATEGORY_HEADER_HEIGHT, EMOJI_HEIGHT, EMOJIS_PER_ROW } from "./EmojiPicker";
import { CATEGORY_HEADER_HEIGHT, EMOJI_HEIGHT, EMOJIS_PER_ROW } from "./config";
import LazyRenderList from "../elements/LazyRenderList";
import Emoji from "./Emoji";
import { type ButtonEvent } from "../elements/AccessibleButton";
@@ -28,10 +28,7 @@ import {
} from "../../../accessibility/RovingTabIndex";
import { Key } from "../../../Keyboard";
import { type ButtonEvent } from "../elements/AccessibleButton";
export const CATEGORY_HEADER_HEIGHT = 20;
export const EMOJI_HEIGHT = 35;
export const EMOJIS_PER_ROW = 8;
import { CATEGORY_HEADER_HEIGHT, EMOJI_HEIGHT, EMOJIS_PER_ROW } from "./config";
const ZERO_WIDTH_JOINER = "\u200D";
@@ -0,0 +1,12 @@
/*
Copyright 2024 New Vector Ltd.
Copyright 2020 The Matrix.org Foundation C.I.C.
Copyright 2019 Tulir Asokan <tulir@maunium.net>
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
export const CATEGORY_HEADER_HEIGHT = 20;
export const EMOJI_HEIGHT = 35;
export const EMOJIS_PER_ROW = 8;
@@ -12,9 +12,8 @@ import { type RoomMember, type IEventRelation } from "matrix-js-sdk/src/matrix";
import { LocationPinIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
import { _t } from "../../../languageHandler";
import { CollapsibleButton } from "../rooms/CollapsibleButton";
import { CollapsibleButton, OverflowMenuContext } from "../rooms/CollapsibleButton";
import { aboveLeftOf, useContextMenu, type MenuProps } from "../../structures/ContextMenu";
import { OverflowMenuContext } from "../rooms/MessageComposerButtons";
import LocationShareMenu from "./LocationShareMenu";
export interface IProps {
@@ -6,12 +6,14 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
Please see LICENSE files in the repository root for full details.
*/
import React, { type RefObject, useContext } from "react";
import React, { type RefObject, useContext, createContext } from "react";
import AccessibleButton, { type ButtonProps } from "../elements/AccessibleButton";
import { OverflowMenuContext } from "./MessageComposerButtons";
import { IconizedContextMenuOption } from "../context_menus/IconizedContextMenu";
type OverflowMenuCloser = () => void;
export const OverflowMenuContext = createContext<OverflowMenuCloser | null>(null);
interface Props extends Omit<ButtonProps<"div">, "element"> {
inputRef?: RefObject<HTMLElement | null>;
title: string;
@@ -13,8 +13,7 @@ import { ReactionIcon } from "@vector-im/compound-design-tokens/assets/web/icons
import { _t } from "../../../languageHandler";
import ContextMenu, { aboveLeftOf, type MenuProps, useContextMenu } from "../../structures/ContextMenu";
import EmojiPicker from "../emojipicker/EmojiPicker";
import { CollapsibleButton } from "./CollapsibleButton";
import { OverflowMenuContext } from "./MessageComposerButtons";
import { CollapsibleButton, OverflowMenuContext } from "./CollapsibleButton";
interface IEmojiButtonProps {
addEmoji: (unicode: string) => boolean;
@@ -15,7 +15,7 @@ import {
THREAD_RELATION_TYPE,
M_POLL_START,
} from "matrix-js-sdk/src/matrix";
import React, { type JSX, createContext, type ReactElement, type ReactNode, useContext } from "react";
import React, { type JSX, type ReactElement, type ReactNode, useContext } from "react";
import {
MicOnIcon,
OverflowHorizontalIcon,
@@ -26,7 +26,7 @@ import {
import { UploadButton, useViewModel } from "@element-hq/web-shared-components";
import { _t } from "../../../languageHandler";
import { CollapsibleButton } from "./CollapsibleButton";
import { CollapsibleButton, OverflowMenuContext } from "./CollapsibleButton";
import { type MenuProps } from "../../structures/ContextMenu";
import ErrorDialog from "../dialogs/ErrorDialog";
import { LocationButton } from "../location";
@@ -62,9 +62,6 @@ interface IProps {
onComposerModeClick: () => void;
}
type OverflowMenuCloser = () => void;
export const OverflowMenuContext = createContext<OverflowMenuCloser | null>(null);
const MessageComposerButtons: React.FC<IProps> = (props: IProps) => {
const matrixClient = useContext(MatrixClientContext);
const roomUploadVM = useRoomUploadViewModel();
@@ -23,7 +23,7 @@ import { type ViewUserPayload } from "../../../dispatcher/payloads/ViewUserPaylo
import { Action } from "../../../dispatcher/actions";
import SpaceStore from "../../../stores/spaces/SpaceStore";
import { showSpaceInvite } from "../../../utils/space";
import { RoomSettingsTab } from "../dialogs/RoomSettingsDialog";
import { RoomSettingsTab } from "../dialogs/RoomSettingsDialog-tab";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
import { shouldShowComponent } from "../../../customisations/helpers/UIComponents";
import { UIComponent } from "../../../settings/UIFeature";
@@ -11,7 +11,7 @@ import { type User } from "matrix-js-sdk/src/matrix";
import { Tooltip } from "@vector-im/compound-web";
import { AutoHideScrollbar } from "@element-hq/web-shared-components";
import ReadReceiptMarker, { type IReadReceiptPosition } from "./ReadReceiptMarker";
import ReadReceiptMarker, { type IReadReceiptPosition, READ_AVATAR_SIZE } from "./ReadReceiptMarker";
import { type IReadReceiptProps } from "./EventTile";
import AccessibleButton from "../elements/AccessibleButton";
import MemberAvatar from "../avatars/MemberAvatar";
@@ -29,7 +29,6 @@ const MAX_READ_AVATARS_PLUS_N = 3;
const MAX_READ_AVATARS = MAX_READ_AVATARS_PLUS_N + 1;
const READ_AVATAR_OFFSET = 10;
export const READ_AVATAR_SIZE = 16;
interface Props {
readReceipts: IReadReceiptProps[];
@@ -14,7 +14,8 @@ import { logger } from "matrix-js-sdk/src/logger";
import NodeAnimator from "../../../NodeAnimator";
import { toPx } from "../../../utils/units";
import MemberAvatar from "../avatars/MemberAvatar";
import { READ_AVATAR_SIZE } from "./ReadReceiptGroup";
export const READ_AVATAR_SIZE = 16;
// The top & right from the bounding client rect of each read receipt
export interface IReadReceiptPosition {
@@ -51,7 +51,7 @@ import WithPresenceIndicator, { useDmMember } from "../../avatars/WithPresenceIn
import { type IOOBData } from "../../../../stores/ThreepidInviteStore.ts";
import { MainSplitContentType } from "../../../../contexts/RoomContext.ts";
import defaultDispatcher from "../../../../dispatcher/dispatcher.ts";
import { RoomSettingsTab } from "../../dialogs/RoomSettingsDialog.tsx";
import { RoomSettingsTab } from "../../dialogs/RoomSettingsDialog-tab";
import { useScopedRoomContext } from "../../../../contexts/ScopedRoomContext.tsx";
import { ToggleableIcon } from "./toggle/ToggleableIcon.tsx";
import { CurrentRightPanelPhaseContextProvider } from "../../../../contexts/CurrentRightPanelPhaseContext.tsx";
@@ -17,7 +17,7 @@ import { _t } from "../../../languageHandler";
import Modal from "../../../Modal";
import MemberAvatar from "../avatars/MemberAvatar";
import ErrorDialog from "../dialogs/ErrorDialog";
import { RoomSettingsTab } from "../dialogs/RoomSettingsDialog";
import { RoomSettingsTab } from "../dialogs/RoomSettingsDialog-tab";
import AccessibleButton from "../elements/AccessibleButton";
import Heading from "../typography/Heading";
import { formatList } from "../../../utils/FormattingUtils";
@@ -11,7 +11,8 @@ import { type MatrixEvent, type Room } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";
import { _t } from "../../../languageHandler";
import { Pill, PillType } from "../elements/Pill";
import { Pill } from "../elements/Pill";
import { PillType } from "../elements/PillType";
import { makeUserPermalink } from "../../../utils/permalinks/Permalinks";
import BaseAvatar from "../avatars/BaseAvatar";
import SettingsStore from "../../../settings/SettingsStore";
@@ -22,7 +22,7 @@ import { type RoomUpgradeProgress, upgradeRoom } from "../../../utils/RoomUpgrad
import { arrayHasDiff } from "../../../utils/arrays";
import { useLocalEcho } from "../../../hooks/useLocalEcho";
import dis from "../../../dispatcher/dispatcher";
import { RoomSettingsTab } from "../dialogs/RoomSettingsDialog";
import { RoomSettingsTab } from "../dialogs/RoomSettingsDialog-tab";
import { Action } from "../../../dispatcher/actions";
import { type ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
import { doesRoomVersionSupport, PreferredRoomVersions } from "../../../utils/PreferredRoomVersions";
+1 -1
View File
@@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details.
import { type MatrixEvent, type Room, type RoomMember } from "matrix-js-sdk/src/matrix";
import { type ButtonEvent } from "../components/views/elements/AccessibleButton";
import { PillType } from "../components/views/elements/Pill";
import { PillType } from "../components/views/elements/PillType";
import { parsePermalink } from "../utils/permalinks/Permalinks";
import dis from "../dispatcher/dispatcher";
import { Action } from "../dispatcher/actions";
+1 -1
View File
@@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details.
import { MatrixEvent, type Room } from "matrix-js-sdk/src/matrix";
import { useEffect, useState } from "react";
import { PillType } from "../components/views/elements/Pill";
import { PillType } from "../components/views/elements/PillType";
import { MatrixClientPeg } from "../MatrixClientPeg";
import { type PermalinkParts } from "../utils/permalinks/PermalinkConstructor";
+1 -1
View File
@@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details.
import { type IMatrixProfile, type MatrixEvent, type Room, RoomMember } from "matrix-js-sdk/src/matrix";
import { useContext, useEffect, useState } from "react";
import { PillType } from "../components/views/elements/Pill";
import { PillType } from "../components/views/elements/PillType";
import { SDKContext, type SdkContextClass } from "../contexts/SDKContext";
import { type PermalinkParts } from "../utils/permalinks/PermalinkConstructor";
+1 -1
View File
@@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details.
import { type Room } from "matrix-js-sdk/src/matrix";
import { useEffect, useState } from "react";
import { PillType } from "../components/views/elements/Pill";
import { PillType } from "../components/views/elements/PillType";
import { MatrixClientPeg } from "../MatrixClientPeg";
import { type PermalinkParts } from "../utils/permalinks/PermalinkConstructor";
+2 -1
View File
@@ -13,7 +13,8 @@ import { textContent } from "domutils";
import reactStringReplace from "react-string-replace";
import { PushProcessor } from "matrix-js-sdk/src/pushprocessor";
import { Pill, PillType } from "../components/views/elements/Pill";
import { Pill } from "../components/views/elements/Pill";
import { PillType } from "../components/views/elements/PillType";
import { parsePermalink } from "../utils/permalinks/Permalinks";
import { type PermalinkParts } from "../utils/permalinks/PermalinkConstructor";
import { hasParentMatching, type RendererMap, type ParentNode } from "./utils.tsx";
+1 -1
View File
@@ -457,7 +457,7 @@ export const SETTINGS: Settings = {
shouldExportToRageshake: false,
},
"blockInvites": {
controller: new BlockInvitesConfigController("blockInvites"),
controller: new BlockInvitesConfigController("blockInvites", defaultWatchManager),
supportedLevels: [SettingLevel.ACCOUNT],
default: false,
},
+2
View File
@@ -40,6 +40,7 @@ import PlatformSettingsHandler from "./handlers/PlatformSettingsHandler";
import ReloadOnChangeController from "./controllers/ReloadOnChangeController";
import { MatrixClientPeg } from "../MatrixClientPeg";
import { MediaPreviewValue } from "../@types/media_preview";
import SettingController from "./controllers/SettingController.ts";
// Convert the settings to easier to manage objects for the handlers
const defaultSettings: Record<string, any> = {};
@@ -887,5 +888,6 @@ export default class SettingsStore {
}
}
SettingController.settingsStore = SettingsStore;
// For debugging purposes
window.mxSettingsStore = SettingsStore;
@@ -10,21 +10,16 @@ import { EventType } from "matrix-js-sdk/src/matrix";
import { type SettingLevel } from "../SettingLevel.ts";
import { _td } from "../../languageHandler.tsx";
import ServerSupportUnstableFeatureController from "./ServerSupportUnstableFeatureController.ts";
import { defaultWatchManager, type SettingKey } from "../Settings.tsx";
import { type SettingKey } from "../Settings.tsx";
import type { WatchManager } from "../WatchManager.ts";
/**
* Handles invite filtering rules provided by MSC4380.
* This handler does not make use of the roomId parameter.
*/
export default class BlockInvitesConfigController extends ServerSupportUnstableFeatureController {
public constructor(settingName: SettingKey) {
super(
settingName,
defaultWatchManager,
[["org.matrix.msc4380.stable"]],
"v1.18",
_td("settings|not_supported"),
);
public constructor(settingName: SettingKey, watchers: WatchManager) {
super(settingName, watchers, [["org.matrix.msc4380.stable"]], "v1.18", _td("settings|not_supported"));
}
public getValueOverride(_level: SettingLevel): boolean {
@@ -8,7 +8,6 @@ Please see LICENSE files in the repository root for full details.
import { ClientEvent, type IClientWellKnown, type MatrixClient } from "matrix-js-sdk/src/matrix";
import { type SettingLevel } from "../SettingLevel";
import SettingsStore from "../SettingsStore.ts";
import MatrixClientBackedController from "./MatrixClientBackedController.ts";
/**
@@ -47,6 +46,6 @@ export default class FallbackIceServerController extends MatrixClientBackedContr
}
public onChange(_level: SettingLevel, _roomId: string | null, _newValue: any): void {
this.client?.setFallbackICEServerAllowed(!!SettingsStore.getValue("fallbackICEServerAllowed"));
this.client?.setFallbackICEServerAllowed(!!this.settingsStore.getValue("fallbackICEServerAllowed"));
}
}
@@ -8,7 +8,6 @@ Please see LICENSE files in the repository root for full details.
import SettingController from "./SettingController";
import { type SettingLevel } from "../SettingLevel";
import SettingsStore from "../SettingsStore";
import { type BooleanSettingKey } from "../Settings.tsx";
import PlatformPeg from "../../PlatformPeg.ts";
@@ -49,9 +48,9 @@ export default class IncompatibleController extends SettingController {
public get incompatibleSetting(): boolean {
if (typeof this.incompatibleValue === "function") {
return this.incompatibleValue(SettingsStore.getValue(this.settingName));
return this.incompatibleValue(this.settingsStore.getValue(this.settingName));
}
return SettingsStore.getValue(this.settingName) === this.incompatibleValue;
return this.settingsStore.getValue(this.settingName) === this.incompatibleValue;
}
public onChange(): void {
@@ -8,7 +8,6 @@ Please see LICENSE files in the repository root for full details.
import { logger as rootLogger } from "matrix-js-sdk/src/logger";
import type { Capabilities } from "matrix-js-sdk/src/matrix";
import SettingsStore from "../SettingsStore";
import type { BooleanSettingKey } from "../Settings.tsx";
import MatrixClientBackedController from "./MatrixClientBackedController.ts";
@@ -60,7 +59,7 @@ export default class RequiresSettingsController extends MatrixClientBackedContro
}
public get settingDisabled(): boolean | string {
if (this.settingNames.some((s) => !SettingsStore.getValue(s))) {
if (this.settingNames.some((s) => !this.settingsStore.getValue(s))) {
return true;
}
return this.isBlockedByCapabilites;
@@ -10,7 +10,6 @@ Please see LICENSE files in the repository root for full details.
import { type SettingLevel } from "../SettingLevel";
import MatrixClientBackedController from "./MatrixClientBackedController";
import { type WatchManager } from "../WatchManager";
import SettingsStore from "../SettingsStore";
import { type SettingKey } from "../Settings.tsx";
import { _t } from "../../languageHandler.tsx";
import PlatformPeg from "../../PlatformPeg.ts";
@@ -63,9 +62,9 @@ export default class ServerSupportUnstableFeatureController extends MatrixClient
public set disabled(newDisabledValue: boolean) {
if (!newDisabledValue === this.enabled) return;
this.enabled = !newDisabledValue;
const level = SettingsStore.firstSupportedLevel(this.settingName);
const level = this.settingsStore.firstSupportedLevel(this.settingName);
if (!level) return;
const settingValue = SettingsStore.getValue(this.settingName, null);
const settingValue = this.settingsStore.getValue(this.settingName, null);
this.watchers.notifyUpdate(this.settingName, null, level, settingValue);
}
@@ -8,6 +8,7 @@ Please see LICENSE files in the repository root for full details.
*/
import { type SettingLevel } from "../SettingLevel";
import type SettingsStore from "../SettingsStore";
/**
* Represents a controller for individual settings to alter the reading behaviour
@@ -18,6 +19,8 @@ import { type SettingLevel } from "../SettingLevel";
* intended to handle environmental factors for specific settings.
*/
export default abstract class SettingController {
public static settingsStore: typeof SettingsStore;
/**
* Gets the overridden value for the setting, if any. This must return null if the
* value is not to be overridden, otherwise it must return the new value.
@@ -66,4 +69,12 @@ export default abstract class SettingController {
public get settingDisabled(): boolean | string {
return false;
}
/**
* Accessor to the SettingsStore injected at runtime.
* Preferred to direct imports in order to avoid import cycles.
*/
protected get settingsStore(): typeof SettingsStore {
return SettingController.settingsStore;
}
}
@@ -9,7 +9,6 @@ Please see LICENSE files in the repository root for full details.
import SettingController from "./SettingController";
import PlatformPeg from "../../PlatformPeg";
import SettingsStore from "../SettingsStore";
import { _t } from "../../languageHandler";
import { SlidingSyncManager } from "../../SlidingSyncManager";
@@ -20,7 +19,7 @@ export default class SlidingSyncController extends SettingController {
public get settingDisabled(): boolean | string {
// Cannot be disabled once enabled, user has been warned and must log out and back in.
if (SettingsStore.getValue("feature_simplified_sliding_sync")) {
if (this.settingsStore.getValue("feature_simplified_sliding_sync")) {
return _t("labs|sliding_sync_disabled_notice");
}
if (!SlidingSyncManager.serverSupportsSlidingSync) {
@@ -7,7 +7,6 @@ Please see LICENSE files in the repository root for full details.
*/
import SettingController from "./SettingController";
import SettingsStore from "../SettingsStore";
import dis from "../../dispatcher/dispatcher";
import { type UpdateSystemFontPayload } from "../../dispatcher/payloads/UpdateSystemFontPayload";
import { Action } from "../../dispatcher/actions";
@@ -21,9 +20,9 @@ export default class SystemFontController extends SettingController {
// Dispatch font size change so that everything open responds to the change.
dis.dispatch<UpdateSystemFontPayload>({
action: Action.UpdateSystemFont,
useBundledEmojiFont: SettingsStore.getValue("useBundledEmojiFont"),
useSystemFont: SettingsStore.getValue("useSystemFont"),
font: SettingsStore.getValue("systemFont"),
useBundledEmojiFont: this.settingsStore.getValue("useBundledEmojiFont"),
useSystemFont: this.settingsStore.getValue("useSystemFont"),
font: this.settingsStore.getValue("systemFont"),
});
}
}
@@ -8,7 +8,6 @@ Please see LICENSE files in the repository root for full details.
import SettingController from "./SettingController";
import { type SettingLevel } from "../SettingLevel";
import SettingsStore from "../SettingsStore";
import { type SettingKey } from "../Settings.tsx";
/**
@@ -40,6 +39,6 @@ export default class UIFeatureController extends SettingController {
}
public get settingDisabled(): boolean {
return !SettingsStore.getValue(this.uiFeatureName);
return !this.settingsStore.getValue(this.uiFeatureName);
}
}
+1 -21
View File
@@ -55,7 +55,7 @@ import { type ViewRoomPayload } from "../dispatcher/payloads/ViewRoomPayload";
import { htmlSerializeFromMdIfNeeded } from "../editor/serialize";
import { leaveRoomBehaviour } from "../utils/leave-behaviour";
import { MatrixClientPeg } from "../MatrixClientPeg";
import { isCurrentLocalRoom, reject, singleMxcUpload, success, successSync } from "./utils";
import { isCurrentLocalRoom, reject, singleMxcUpload, success, successSync, splitAtFirstSpace } from "./utils";
import { deop, op } from "./op";
import { CommandCategories } from "./interface";
import { Command } from "./command";
@@ -892,26 +892,6 @@ interface ICmd {
args?: string;
}
/**
* Split the supplied string into one or two strings separated by the first
* region of white space we can find.
*/
export function splitAtFirstSpace(args: string): [string, string?] {
const trimmedArgs = args.trim();
const i = trimmedArgs.search(/\s+/);
if (i === -1) {
return [trimmedArgs];
} else {
const first = trimmedArgs.slice(0, i);
const second = trimmedArgs.slice(i + 1).trimStart();
if (second === "") {
return [first];
} else {
return [first, second];
}
}
}
/**
* Process the given text for /commands and returns a parsed command that can be used for running the operation.
* @param {string} roomId The room ID where the command was issued.
+3 -2
View File
@@ -7,9 +7,10 @@ Please see LICENSE files in the repository root for full details.
import { _td } from "@element-hq/web-shared-components";
import { Command, CommandCategories, splitAtFirstSpace } from "./SlashCommands";
import { Command } from "./command";
import { CommandCategories } from "./interface";
import SettingsStore from "../settings/SettingsStore";
import { reject, success } from "./utils";
import { reject, success, splitAtFirstSpace } from "./utils";
import { UserFriendlyError } from "../languageHandler";
import { TimelineRenderingType } from "../contexts/RoomContext";
import { setUserStatus, userStatusTextWithinMaxLength } from "../utils/userStatus";
+20
View File
@@ -76,3 +76,23 @@ export const isCurrentLocalRoom = (cli: MatrixClient | null): boolean => {
if (!room) return false;
return isLocalRoom(room);
};
/**
* Split the supplied string into one or two strings separated by the first
* region of white space we can find.
*/
export function splitAtFirstSpace(args: string): [string, string?] {
const trimmedArgs = args.trim();
const i = trimmedArgs.search(/\s+/);
if (i === -1) {
return [trimmedArgs];
} else {
const first = trimmedArgs.slice(0, i);
const second = trimmedArgs.slice(i + 1).trimStart();
if (second === "") {
return [first];
} else {
return [first, second];
}
}
}
-4
View File
@@ -68,10 +68,6 @@ const onLearnMorePreviouslyOptedIn = (): void => {
const TOAST_KEY = "analytics";
export function getPolicyUrl(): string | undefined {
return SdkConfig.get("privacy_policy_url");
}
export const showToast = (): void => {
const legacyAnalyticsOptIn = SettingsStore.getValue("analyticsOptIn", null, true);
@@ -13,7 +13,8 @@ import { mocked, type Mocked } from "jest-mock";
import { type MatrixClient, type MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
import dis from "../../../../../src/dispatcher/dispatcher";
import { Pill, type PillProps, PillType } from "../../../../../src/components/views/elements/Pill";
import { Pill, type PillProps } from "../../../../../src/components/views/elements/Pill";
import { PillType } from "../../../../../src/components/views/elements/PillType";
import {
filterConsole,
flushPromises,
@@ -21,7 +21,7 @@ import { KnownMembership } from "matrix-js-sdk/src/types";
import React from "react";
import ErrorDialog from "../../../../../src/components/views/dialogs/ErrorDialog";
import { RoomSettingsTab } from "../../../../../src/components/views/dialogs/RoomSettingsDialog";
import { RoomSettingsTab } from "../../../../../src/components/views/dialogs/RoomSettingsDialog-tab";
import { RoomKnocksBar } from "../../../../../src/components/views/rooms/RoomKnocksBar";
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
import dis from "../../../../../src/dispatcher/dispatcher";
@@ -5,7 +5,7 @@
* Please see LICENSE files in the repository root for full details.
*/
import { splitAtFirstSpace } from "../../../src/slash-commands/SlashCommands";
import { splitAtFirstSpace } from "../../../src/slash-commands/utils";
describe("splitAtFirstSpace", () => {
it("should be able to split arguments at the first whitespace", () => {