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