Eliminate the use of MatrixClientPeg in utils (#10910)

This commit is contained in:
Michael Telatynski 2023-05-23 16:24:12 +01:00 committed by GitHub
parent a0c2676c38
commit 30429df948
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
108 changed files with 409 additions and 325 deletions

View file

@ -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.")

View file

@ -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>
),