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
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue