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