Eliminate the use of MatrixClientPeg in utils (#10910)
This commit is contained in:
parent
a0c2676c38
commit
30429df948
108 changed files with 409 additions and 325 deletions
|
@ -28,7 +28,7 @@ import { OwnProfileStore } from "../../stores/OwnProfileStore";
|
|||
import AccessibleButton, { ButtonEvent } from "../views/elements/AccessibleButton";
|
||||
import { UPDATE_EVENT } from "../../stores/AsyncStore";
|
||||
import { useEventEmitter } from "../../hooks/useEventEmitter";
|
||||
import MatrixClientContext from "../../contexts/MatrixClientContext";
|
||||
import MatrixClientContext, { useMatrixClientContext } from "../../contexts/MatrixClientContext";
|
||||
import MiniAvatarUploader, { AVATAR_SIZE } from "../views/elements/MiniAvatarUploader";
|
||||
import PosthogTrackers from "../../PosthogTrackers";
|
||||
import EmbeddedPage from "./EmbeddedPage";
|
||||
|
@ -97,8 +97,9 @@ const UserWelcomeTop: React.FC = () => {
|
|||
};
|
||||
|
||||
const HomePage: React.FC<IProps> = ({ justRegistered = false }) => {
|
||||
const cli = useMatrixClientContext();
|
||||
const config = SdkConfig.get();
|
||||
const pageUrl = getHomePageUrl(config);
|
||||
const pageUrl = getHomePageUrl(config, cli);
|
||||
|
||||
if (pageUrl) {
|
||||
return <EmbeddedPage className="mx_HomePage" url={pageUrl} scrollbar={true} />;
|
||||
|
|
|
@ -1154,7 +1154,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
|
||||
private leaveRoom(roomId: string): void {
|
||||
const roomToLeave = MatrixClientPeg.get().getRoom(roomId);
|
||||
const cli = MatrixClientPeg.get();
|
||||
const roomToLeave = cli.getRoom(roomId);
|
||||
const warnings = this.leaveRoomWarnings(roomId);
|
||||
|
||||
const isSpace = roomToLeave?.isSpaceRoom();
|
||||
|
@ -1173,9 +1174,9 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
</span>
|
||||
),
|
||||
button: _t("Leave"),
|
||||
onFinished: (shouldLeave) => {
|
||||
onFinished: async (shouldLeave) => {
|
||||
if (shouldLeave) {
|
||||
leaveRoomBehaviour(roomId);
|
||||
await leaveRoomBehaviour(cli, roomId);
|
||||
|
||||
dis.dispatch<AfterLeaveRoomPayload>({
|
||||
action: Action.AfterLeaveRoom,
|
||||
|
@ -1211,7 +1212,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
|
||||
private async copyRoom(roomId: string): Promise<void> {
|
||||
const roomLink = makeRoomPermalink(roomId);
|
||||
const roomLink = makeRoomPermalink(MatrixClientPeg.get(), roomId);
|
||||
const success = await copyPlaintext(roomLink);
|
||||
if (!success) {
|
||||
Modal.createDialog(ErrorDialog, {
|
||||
|
|
|
@ -743,7 +743,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
|
|||
lastInSection =
|
||||
willWantDateSeparator ||
|
||||
mxEv.getSender() !== nextEv.getSender() ||
|
||||
getEventDisplayInfo(nextEv, this.showHiddenEvents).isInfoMessage ||
|
||||
getEventDisplayInfo(MatrixClientPeg.get(), nextEv, this.showHiddenEvents).isInfoMessage ||
|
||||
!shouldFormContinuation(mxEv, nextEv, this.showHiddenEvents, this.context.timelineRenderingType);
|
||||
}
|
||||
|
||||
|
|
|
@ -561,7 +561,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
|||
createdByCurrentUserTs - lastCreatedByOtherTs < PREVENT_MULTIPLE_JITSI_WITHIN
|
||||
) {
|
||||
// more than one Jitsi widget with the last one from the current user → remove it
|
||||
WidgetUtils.setRoomWidget(this.state.roomId, createdByCurrentUser.id);
|
||||
WidgetUtils.setRoomWidget(this.context.client, this.state.roomId, createdByCurrentUser.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -549,7 +549,7 @@ const SpaceSetupPrivateInvite: React.FC<{
|
|||
setBusy(true);
|
||||
const targetIds = emailAddresses.map((name) => name.trim()).filter(Boolean);
|
||||
try {
|
||||
const result = await inviteMultipleToRoom(space.roomId, targetIds);
|
||||
const result = await inviteMultipleToRoom(space.client, space.roomId, targetIds);
|
||||
|
||||
const failedUsers = Object.keys(result.states).filter((a) => result.states[a] === "error");
|
||||
if (failedUsers.length > 0) {
|
||||
|
|
|
@ -110,7 +110,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
|||
}
|
||||
|
||||
private get hasHomePage(): boolean {
|
||||
return !!getHomePageUrl(SdkConfig.get());
|
||||
return !!getHomePageUrl(SdkConfig.get(), this.context.client!);
|
||||
}
|
||||
|
||||
private onCurrentVoiceBroadcastRecordingChanged = (recording: VoiceBroadcastRecording | null): void => {
|
||||
|
|
|
@ -153,7 +153,9 @@ export default class ViewSource extends React.Component<IProps, IState> {
|
|||
const isEditing = this.state.isEditing;
|
||||
const roomId = mxEvent.getRoomId()!;
|
||||
const eventId = mxEvent.getId()!;
|
||||
const canEdit = mxEvent.isState() ? this.canSendStateEvent(mxEvent) : canEditContent(this.props.mxEvent);
|
||||
const canEdit = mxEvent.isState()
|
||||
? this.canSendStateEvent(mxEvent)
|
||||
: canEditContent(MatrixClientPeg.get(), this.props.mxEvent);
|
||||
return (
|
||||
<BaseDialog className="mx_ViewSource" onFinished={this.props.onFinished} title={_t("View Source")}>
|
||||
<div className="mx_ViewSource_header">
|
||||
|
|
|
@ -22,6 +22,7 @@ import SdkConfig from "../../../SdkConfig";
|
|||
import withValidation, { IFieldState, IValidationResult } from "../elements/Validation";
|
||||
import { _t, _td } from "../../../languageHandler";
|
||||
import Field, { IInputProps } from "../elements/Field";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
|
||||
interface IProps extends Omit<IInputProps, "onValidate" | "element"> {
|
||||
autoFocus?: boolean;
|
||||
|
@ -56,7 +57,7 @@ class PassphraseField extends PureComponent<IProps> {
|
|||
deriveData: async ({ value }): Promise<zxcvbn.ZXCVBNResult | null> => {
|
||||
if (!value) return null;
|
||||
const { scorePassword } = await import("../../../utils/PasswordScorer");
|
||||
return scorePassword(value);
|
||||
return scorePassword(MatrixClientPeg.get(), value);
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
|
|
|
@ -165,7 +165,7 @@ export default class DecoratedRoomAvatar extends React.PureComponent<IProps, ISt
|
|||
const otherUserId = DMRoomMap.shared().getUserIdForRoomId(this.props.room.roomId);
|
||||
if (otherUserId && this.props.room.getJoinedMemberCount() === 2) {
|
||||
// Track presence, if available
|
||||
if (isPresenceEnabled()) {
|
||||
if (isPresenceEnabled(this.props.room.client)) {
|
||||
this.dmUser = MatrixClientPeg.get().getUser(otherUserId);
|
||||
icon = this.getPresenceIcon();
|
||||
}
|
||||
|
|
|
@ -317,7 +317,12 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
|
|||
};
|
||||
|
||||
private onEditClick = (): void => {
|
||||
editEvent(this.props.mxEvent, this.context.timelineRenderingType, this.props.getRelationsForEvent);
|
||||
editEvent(
|
||||
MatrixClientPeg.get(),
|
||||
this.props.mxEvent,
|
||||
this.context.timelineRenderingType,
|
||||
this.props.getRelationsForEvent,
|
||||
);
|
||||
this.closeMenu();
|
||||
};
|
||||
|
||||
|
@ -617,7 +622,7 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
|
|||
}
|
||||
|
||||
let editButton: JSX.Element | undefined;
|
||||
if (rightClick && canEditContent(mxEvent)) {
|
||||
if (rightClick && canEditContent(cli, mxEvent)) {
|
||||
editButton = (
|
||||
<IconizedContextMenuOption
|
||||
iconClassName="mx_MessageContextMenu_iconEdit"
|
||||
|
|
|
@ -61,7 +61,7 @@ export const WidgetContextMenu: React.FC<IProps> = ({
|
|||
const { room, roomId } = useContext(RoomContext);
|
||||
|
||||
const widgetMessaging = WidgetMessagingStore.instance.getMessagingForUid(WidgetUtils.getWidgetUid(app));
|
||||
const canModify = userWidget || WidgetUtils.canUserModifyWidgets(roomId);
|
||||
const canModify = userWidget || WidgetUtils.canUserModifyWidgets(cli, roomId);
|
||||
|
||||
let streamAudioStreamButton: JSX.Element | undefined;
|
||||
if (roomId && getConfigLivestreamUrl() && WidgetType.JITSI.matches(app.type)) {
|
||||
|
@ -138,7 +138,7 @@ export const WidgetContextMenu: React.FC<IProps> = ({
|
|||
button: _t("Delete widget"),
|
||||
onFinished: (confirmed) => {
|
||||
if (!confirmed) return;
|
||||
WidgetUtils.setRoomWidget(roomId, app.id);
|
||||
WidgetUtils.setRoomWidget(cli, roomId, app.id);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -75,9 +75,10 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
|||
joinRule = JoinRule.Restricted;
|
||||
}
|
||||
|
||||
const cli = MatrixClientPeg.get();
|
||||
this.state = {
|
||||
isPublic: this.props.defaultPublic || false,
|
||||
isEncrypted: this.props.defaultEncrypted ?? privateShouldBeEncrypted(),
|
||||
isEncrypted: this.props.defaultEncrypted ?? privateShouldBeEncrypted(cli),
|
||||
joinRule,
|
||||
name: this.props.defaultName || "",
|
||||
topic: "",
|
||||
|
@ -88,9 +89,9 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
|||
canChangeEncryption: true,
|
||||
};
|
||||
|
||||
MatrixClientPeg.get()
|
||||
.doesServerForceEncryptionForPreset(Preset.PrivateChat)
|
||||
.then((isForced) => this.setState({ canChangeEncryption: !isForced }));
|
||||
cli.doesServerForceEncryptionForPreset(Preset.PrivateChat).then((isForced) =>
|
||||
this.setState({ canChangeEncryption: !isForced }),
|
||||
);
|
||||
}
|
||||
|
||||
private roomCreateOptions(): IOpts {
|
||||
|
@ -284,7 +285,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
|||
let e2eeSection: JSX.Element | undefined;
|
||||
if (this.state.joinRule !== JoinRule.Public) {
|
||||
let microcopy: string;
|
||||
if (privateShouldBeEncrypted()) {
|
||||
if (privateShouldBeEncrypted(MatrixClientPeg.get())) {
|
||||
if (this.state.canChangeEncryption) {
|
||||
microcopy = isVideoRoom
|
||||
? _t("You can't disable this later. The room will be encrypted but the embedded call will not.")
|
||||
|
|
|
@ -407,7 +407,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
this.encryptionByDefault = privateShouldBeEncrypted();
|
||||
this.encryptionByDefault = privateShouldBeEncrypted(MatrixClientPeg.get());
|
||||
|
||||
if (this.props.initialText) {
|
||||
this.updateSuggestions(this.props.initialText);
|
||||
|
@ -613,7 +613,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
}
|
||||
|
||||
try {
|
||||
const result = await inviteMultipleToRoom(this.props.roomId, targetIds, true);
|
||||
const result = await inviteMultipleToRoom(cli, this.props.roomId, targetIds, true);
|
||||
if (!this.shouldAbortAfterInviteError(result, room)) {
|
||||
// handles setting error message too
|
||||
this.props.onFinished(true);
|
||||
|
@ -986,7 +986,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
|
||||
// Update the IS in account data. Actually using it may trigger terms.
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
setToDefaultIdentityServer();
|
||||
setToDefaultIdentityServer(MatrixClientPeg.get());
|
||||
this.setState({ canUseIdentityServer: true, tryingIdentityServer: false });
|
||||
};
|
||||
|
||||
|
@ -1395,7 +1395,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
</a>
|
||||
),
|
||||
a: (sub) => (
|
||||
<a href={makeRoomPermalink(roomId)} rel="noreferrer noopener" target="_blank">
|
||||
<a href={makeRoomPermalink(cli, roomId)} rel="noreferrer noopener" target="_blank">
|
||||
{sub}
|
||||
</a>
|
||||
),
|
||||
|
|
|
@ -76,7 +76,7 @@ class LocationPicker extends React.Component<ILocationPickerProps, IState> {
|
|||
try {
|
||||
this.map = new maplibregl.Map({
|
||||
container: "mx_LocationPicker_map",
|
||||
style: findMapStyleUrl(),
|
||||
style: findMapStyleUrl(this.context),
|
||||
center: [0, 0],
|
||||
zoom: 1,
|
||||
});
|
||||
|
|
|
@ -101,7 +101,7 @@ export default class EditHistoryMessage extends React.PureComponent<IProps, ISta
|
|||
private pillifyLinks(): void {
|
||||
// not present for redacted events
|
||||
if (this.content.current) {
|
||||
pillifyLinks(this.content.current.children, this.props.mxEvent, this.pills);
|
||||
pillifyLinks(MatrixClientPeg.get(), this.content.current.children, this.props.mxEvent, this.pills);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,16 +114,18 @@ export default class MKeyVerificationConclusion extends React.Component<IProps>
|
|||
|
||||
if (request.done) {
|
||||
title = _t("You verified %(name)s", {
|
||||
name: getNameForEventRoom(request.otherUserId, mxEvent.getRoomId()!),
|
||||
name: getNameForEventRoom(client, request.otherUserId, mxEvent.getRoomId()!),
|
||||
});
|
||||
} else if (request.cancelled) {
|
||||
const userId = request.cancellingUserId;
|
||||
if (userId === myUserId) {
|
||||
title = _t("You cancelled verifying %(name)s", {
|
||||
name: getNameForEventRoom(request.otherUserId, mxEvent.getRoomId()!),
|
||||
name: getNameForEventRoom(client, request.otherUserId, mxEvent.getRoomId()!),
|
||||
});
|
||||
} else if (userId) {
|
||||
title = _t("%(name)s cancelled verifying", { name: getNameForEventRoom(userId, mxEvent.getRoomId()!) });
|
||||
title = _t("%(name)s cancelled verifying", {
|
||||
name: getNameForEventRoom(client, userId, mxEvent.getRoomId()!),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,7 +137,7 @@ export default class MKeyVerificationConclusion extends React.Component<IProps>
|
|||
<EventTileBubble
|
||||
className={classes}
|
||||
title={title}
|
||||
subtitle={userLabelForEventRoom(request.otherUserId, mxEvent.getRoomId()!)}
|
||||
subtitle={userLabelForEventRoom(client, request.otherUserId, mxEvent.getRoomId()!)}
|
||||
timestamp={this.props.timestamp}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -93,7 +93,9 @@ export default class MKeyVerificationRequest extends React.Component<IProps> {
|
|||
if (userId === myUserId) {
|
||||
return _t("You accepted");
|
||||
} else {
|
||||
return _t("%(name)s accepted", { name: getNameForEventRoom(userId, this.props.mxEvent.getRoomId()!) });
|
||||
return _t("%(name)s accepted", {
|
||||
name: getNameForEventRoom(client, userId, this.props.mxEvent.getRoomId()!),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,14 +112,19 @@ export default class MKeyVerificationRequest extends React.Component<IProps> {
|
|||
}
|
||||
} else {
|
||||
if (declined) {
|
||||
return _t("%(name)s declined", { name: getNameForEventRoom(userId, this.props.mxEvent.getRoomId()!) });
|
||||
return _t("%(name)s declined", {
|
||||
name: getNameForEventRoom(client, userId, this.props.mxEvent.getRoomId()!),
|
||||
});
|
||||
} else {
|
||||
return _t("%(name)s cancelled", { name: getNameForEventRoom(userId, this.props.mxEvent.getRoomId()!) });
|
||||
return _t("%(name)s cancelled", {
|
||||
name: getNameForEventRoom(client, userId, this.props.mxEvent.getRoomId()!),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public render(): React.ReactNode {
|
||||
const client = MatrixClientPeg.get();
|
||||
const { mxEvent } = this.props;
|
||||
const request = mxEvent.verificationRequest;
|
||||
|
||||
|
@ -149,9 +156,9 @@ export default class MKeyVerificationRequest extends React.Component<IProps> {
|
|||
}
|
||||
|
||||
if (!request.initiatedByMe) {
|
||||
const name = getNameForEventRoom(request.requestingUserId, mxEvent.getRoomId()!);
|
||||
const name = getNameForEventRoom(client, request.requestingUserId, mxEvent.getRoomId()!);
|
||||
title = _t("%(name)s wants to verify", { name });
|
||||
subtitle = userLabelForEventRoom(request.requestingUserId, mxEvent.getRoomId()!);
|
||||
subtitle = userLabelForEventRoom(client, request.requestingUserId, mxEvent.getRoomId()!);
|
||||
if (request.canAccept) {
|
||||
stateNode = (
|
||||
<div className="mx_cryptoEvent_buttons">
|
||||
|
@ -167,7 +174,7 @@ export default class MKeyVerificationRequest extends React.Component<IProps> {
|
|||
} else {
|
||||
// request sent by us
|
||||
title = _t("You sent a verification request");
|
||||
subtitle = userLabelForEventRoom(request.receivingUserId, mxEvent.getRoomId()!);
|
||||
subtitle = userLabelForEventRoom(client, request.receivingUserId, mxEvent.getRoomId()!);
|
||||
}
|
||||
|
||||
if (title) {
|
||||
|
|
|
@ -363,7 +363,12 @@ export default class MessageActionBar extends React.PureComponent<IMessageAction
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
editEvent(this.props.mxEvent, this.context.timelineRenderingType, this.props.getRelationsForEvent);
|
||||
editEvent(
|
||||
MatrixClientPeg.get(),
|
||||
this.props.mxEvent,
|
||||
this.context.timelineRenderingType,
|
||||
this.props.getRelationsForEvent,
|
||||
);
|
||||
};
|
||||
|
||||
private readonly forbiddenThreadHeadMsgType = [MsgType.KeyVerificationRequest];
|
||||
|
@ -424,7 +429,7 @@ export default class MessageActionBar extends React.PureComponent<IMessageAction
|
|||
|
||||
public render(): React.ReactNode {
|
||||
const toolbarOpts: JSX.Element[] = [];
|
||||
if (canEditContent(this.props.mxEvent)) {
|
||||
if (canEditContent(MatrixClientPeg.get(), this.props.mxEvent)) {
|
||||
toolbarOpts.push(
|
||||
<RovingAccessibleTooltipButton
|
||||
className="mx_MessageActionBar_iconButton"
|
||||
|
|
|
@ -48,6 +48,7 @@ import { options as linkifyOpts } from "../../../linkify-matrix";
|
|||
import { getParentEventId } from "../../../utils/Reply";
|
||||
import { EditWysiwygComposer } from "../rooms/wysiwyg_composer";
|
||||
import { IEventTileOps } from "../rooms/EventTile";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
|
||||
const MAX_HIGHLIGHT_LENGTH = 4096;
|
||||
|
||||
|
@ -92,7 +93,7 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
|
|||
this.activateSpoilers([content]);
|
||||
|
||||
HtmlUtils.linkifyElement(content);
|
||||
pillifyLinks([content], this.props.mxEvent, this.pills);
|
||||
pillifyLinks(MatrixClientPeg.get(), [content], this.props.mxEvent, this.pills);
|
||||
|
||||
this.calculateUrlPreview();
|
||||
|
||||
|
|
|
@ -108,8 +108,8 @@ const AppRow: React.FC<IAppRowProps> = ({ app, room }) => {
|
|||
const [canModifyWidget, setCanModifyWidget] = useState<boolean>();
|
||||
|
||||
useEffect(() => {
|
||||
setCanModifyWidget(WidgetUtils.canUserModifyWidgets(room.roomId));
|
||||
}, [room.roomId]);
|
||||
setCanModifyWidget(WidgetUtils.canUserModifyWidgets(room.client, room.roomId));
|
||||
}, [room.client, room.roomId]);
|
||||
|
||||
const onOpenWidgetClick = (): void => {
|
||||
RightPanelStore.instance.pushCard({
|
||||
|
|
|
@ -456,7 +456,7 @@ export const UserOptionsSection: React.FC<{
|
|||
const onInviteUserButton = async (ev: ButtonEvent): Promise<void> => {
|
||||
try {
|
||||
// We use a MultiInviter to re-use the invite logic, even though we're only inviting one user.
|
||||
const inviter = new MultiInviter(roomId || "");
|
||||
const inviter = new MultiInviter(cli, roomId || "");
|
||||
await inviter.invite([member.userId]).then(() => {
|
||||
if (inviter.getCompletionState(member.userId) !== "invited") {
|
||||
const errorStringFromInviterUtility = inviter.getErrorText(member.userId);
|
||||
|
|
|
@ -50,6 +50,7 @@ import { editorRoomKey, editorStateKey } from "../../../Editing";
|
|||
import DocumentOffset from "../../../editor/offset";
|
||||
import { attachMentions, attachRelation } from "./SendMessageComposer";
|
||||
import { filterBoolean } from "../../../utils/arrays";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
|
||||
function getHtmlReplyFallback(mxEvent: MatrixEvent): string {
|
||||
const html = mxEvent.getContent().formatted_body;
|
||||
|
@ -184,6 +185,7 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
|
|||
events: this.events,
|
||||
isForward: false,
|
||||
fromEventId: this.props.editState.getEvent().getId(),
|
||||
matrixClient: MatrixClientPeg.get(),
|
||||
});
|
||||
if (previousEvent) {
|
||||
dis.dispatch({
|
||||
|
@ -203,6 +205,7 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
|
|||
events: this.events,
|
||||
isForward: true,
|
||||
fromEventId: this.props.editState.getEvent().getId(),
|
||||
matrixClient: MatrixClientPeg.get(),
|
||||
});
|
||||
if (nextEvent) {
|
||||
dis.dispatch({
|
||||
|
|
|
@ -34,7 +34,6 @@ import dis from "../../../dispatcher/dispatcher";
|
|||
import { Layout } from "../../../settings/enums/Layout";
|
||||
import { formatTime } from "../../../DateUtils";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||
import { DecryptionFailureBody } from "../messages/DecryptionFailureBody";
|
||||
import { E2EState } from "./E2EIcon";
|
||||
import RoomAvatar from "../avatars/RoomAvatar";
|
||||
|
@ -267,7 +266,7 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
|
|||
|
||||
private unmounted = false;
|
||||
|
||||
public constructor(props: EventTileProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||
public constructor(props: EventTileProps, context: React.ContextType<typeof RoomContext>) {
|
||||
super(props, context);
|
||||
|
||||
const thread = this.thread;
|
||||
|
@ -904,7 +903,12 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
|
|||
isLeftAlignedBubbleMessage,
|
||||
noBubbleEvent,
|
||||
isSeeingThroughMessageHiddenForModeration,
|
||||
} = getEventDisplayInfo(this.props.mxEvent, this.context.showHiddenEvents, this.shouldHideEvent());
|
||||
} = getEventDisplayInfo(
|
||||
MatrixClientPeg.get(),
|
||||
this.props.mxEvent,
|
||||
this.context.showHiddenEvents,
|
||||
this.shouldHideEvent(),
|
||||
);
|
||||
const { isQuoteExpanded } = this.state;
|
||||
// This shouldn't happen: the caller should check we support this type
|
||||
// before trying to instantiate us
|
||||
|
|
|
@ -527,7 +527,7 @@ export class MessageComposer extends React.Component<IProps, IState> {
|
|||
|
||||
const continuesLink = replacementRoomId ? (
|
||||
<a
|
||||
href={makeRoomPermalink(replacementRoomId)}
|
||||
href={makeRoomPermalink(MatrixClientPeg.get(), replacementRoomId)}
|
||||
className="mx_MessageComposer_roomReplaced_link"
|
||||
onClick={this.onTombstoneClick}
|
||||
>
|
||||
|
|
|
@ -44,7 +44,7 @@ import { shouldEncryptRoomWithSingle3rdPartyInvite } from "../../../utils/room/s
|
|||
function hasExpectedEncryptionSettings(matrixClient: MatrixClient, room: Room): boolean {
|
||||
const isEncrypted: boolean = matrixClient.isRoomEncrypted(room.roomId);
|
||||
const isPublic: boolean = room.getJoinRule() === "public";
|
||||
return isPublic || !privateShouldBeEncrypted() || isEncrypted;
|
||||
return isPublic || !privateShouldBeEncrypted(matrixClient) || isEncrypted;
|
||||
}
|
||||
|
||||
const determineIntroMessage = (room: Room, encryptedSingle3rdPartyInvite: boolean): string => {
|
||||
|
|
|
@ -34,6 +34,7 @@ import MVoiceMessageBody from "../messages/MVoiceMessageBody";
|
|||
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
|
||||
import { renderReplyTile } from "../../../events/EventTileFactory";
|
||||
import { GetRelationsForEvent } from "../rooms/EventTile";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
|
||||
interface IProps {
|
||||
mxEvent: MatrixEvent;
|
||||
|
@ -110,6 +111,7 @@ export default class ReplyTile extends React.PureComponent<IProps> {
|
|||
const evType = mxEvent.getType();
|
||||
|
||||
const { hasRenderer, isInfoMessage, isSeeingThroughMessageHiddenForModeration } = getEventDisplayInfo(
|
||||
MatrixClientPeg.get(),
|
||||
mxEvent,
|
||||
false /* Replies are never hidden, so this should be fine */,
|
||||
);
|
||||
|
|
|
@ -335,6 +335,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
? findEditableEvent({
|
||||
events,
|
||||
isForward: false,
|
||||
matrixClient: MatrixClientPeg.get(),
|
||||
})
|
||||
: undefined;
|
||||
if (editEvent) {
|
||||
|
|
|
@ -123,7 +123,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
|
||||
this.props.setStickerPickerOpen(false);
|
||||
WidgetUtils.removeStickerpickerWidgets()
|
||||
WidgetUtils.removeStickerpickerWidgets(this.props.room.client)
|
||||
.then(() => {
|
||||
this.forceUpdate();
|
||||
})
|
||||
|
@ -169,7 +169,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
|
||||
private updateWidget = (): void => {
|
||||
const stickerpickerWidget = WidgetUtils.getStickerpickerWidgets()[0];
|
||||
const stickerpickerWidget = WidgetUtils.getStickerpickerWidgets(this.props.room.client)[0];
|
||||
if (!stickerpickerWidget) {
|
||||
Stickerpicker.currentWidget = undefined;
|
||||
this.setState({ stickerpickerWidget: null, widgetId: null });
|
||||
|
|
|
@ -146,8 +146,10 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
|
|||
});
|
||||
}
|
||||
|
||||
doMaybeLocalRoomAction(this.props.room.roomId, (actualRoomId: string) =>
|
||||
MatrixClientPeg.get().sendMessage(actualRoomId, content),
|
||||
doMaybeLocalRoomAction(
|
||||
this.props.room.roomId,
|
||||
(actualRoomId: string) => MatrixClientPeg.get().sendMessage(actualRoomId, content),
|
||||
this.props.room.client,
|
||||
);
|
||||
} catch (e) {
|
||||
logger.error("Error sending voice message:", e);
|
||||
|
|
|
@ -185,6 +185,7 @@ function dispatchEditEvent(
|
|||
events: foundEvents,
|
||||
isForward,
|
||||
fromEventId: editorStateTransfer?.getEvent().getId(),
|
||||
matrixClient: mxClient,
|
||||
});
|
||||
if (newEvent) {
|
||||
dis.dispatch({
|
||||
|
|
|
@ -419,7 +419,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
|
|||
</AccessibleButton>,
|
||||
);
|
||||
|
||||
if (!isSecureBackupRequired()) {
|
||||
if (!isSecureBackupRequired(MatrixClientPeg.get())) {
|
||||
actions.push(
|
||||
<AccessibleButton key="delete" kind="danger" onClick={this.deleteBackup}>
|
||||
{_t("Delete Backup")}
|
||||
|
|
|
@ -179,7 +179,7 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
let save = true;
|
||||
|
||||
// Double check that the identity server even has terms of service.
|
||||
const hasTerms = await doesIdentityServerHaveTerms(fullUrl);
|
||||
const hasTerms = await doesIdentityServerHaveTerms(MatrixClientPeg.get(), fullUrl);
|
||||
if (!hasTerms) {
|
||||
const [confirmed] = await this.showNoTermsWarning(fullUrl);
|
||||
save = !!confirmed;
|
||||
|
|
|
@ -316,7 +316,7 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
);
|
||||
|
||||
let warning;
|
||||
if (!privateShouldBeEncrypted()) {
|
||||
if (!privateShouldBeEncrypted(MatrixClientPeg.get())) {
|
||||
warning = (
|
||||
<div className="mx_SecurityUserSettingsTab_warning">
|
||||
{_t(
|
||||
|
|
|
@ -165,7 +165,7 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
|
|||
} else {
|
||||
const userId = request.otherUserId;
|
||||
const roomId = request.channel.roomId;
|
||||
description = roomId ? userLabelForEventRoom(userId, roomId) : userId;
|
||||
description = roomId ? userLabelForEventRoom(MatrixClientPeg.get(), userId, roomId) : userId;
|
||||
// for legacy to_device verification requests
|
||||
if (description === userId) {
|
||||
const client = MatrixClientPeg.get();
|
||||
|
|
|
@ -30,6 +30,7 @@ import EmbeddedPage from "../../structures/EmbeddedPage";
|
|||
import HomePage from "../../structures/HomePage";
|
||||
import { UserOnboardingHeader } from "./UserOnboardingHeader";
|
||||
import { UserOnboardingList } from "./UserOnboardingList";
|
||||
import { useMatrixClientContext } from "../../../contexts/MatrixClientContext";
|
||||
|
||||
interface Props {
|
||||
justRegistered?: boolean;
|
||||
|
@ -44,8 +45,9 @@ export function showUserOnboardingPage(useCase: UseCase | null): boolean {
|
|||
|
||||
const ANIMATION_DURATION = 2800;
|
||||
export function UserOnboardingPage({ justRegistered = false }: Props): JSX.Element {
|
||||
const cli = useMatrixClientContext();
|
||||
const config = SdkConfig.get();
|
||||
const pageUrl = getHomePageUrl(config);
|
||||
const pageUrl = getHomePageUrl(config, cli);
|
||||
|
||||
const useCase = useSettingValue<UseCase | null>("FTUE.useCaseSelection");
|
||||
const context = useUserOnboardingContext();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue