Pass around MatrixClients instead of using MatrixClientPeg (#11000)

This commit is contained in:
Michael Telatynski 2023-05-30 10:36:34 +01:00 committed by GitHub
parent aa5a2e1363
commit 938aefc51c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 176 additions and 141 deletions

View file

@ -181,7 +181,7 @@ export default class EmailAddresses extends React.Component<IProps, IState> {
return;
}
const task = new AddThreepid();
const task = new AddThreepid(MatrixClientPeg.get());
this.setState({ verifying: true, continueDisabled: true, addTask: task });
task.addEmailAddress(email)

View file

@ -182,7 +182,7 @@ export default class PhoneNumbers extends React.Component<IProps, IState> {
const phoneNumber = this.state.newPhoneNumber;
const phoneCountry = this.state.phoneCountry;
const task = new AddThreepid();
const task = new AddThreepid(MatrixClientPeg.get());
this.setState({ verifying: true, continueDisabled: true, addTask: task });
task.addMsisdn(phoneCountry, phoneNumber)

View file

@ -86,7 +86,7 @@ export class EmailAddress extends React.Component<IEmailAddressProps, IEmailAddr
try {
if (bind) {
const task = new AddThreepid();
const task = new AddThreepid(MatrixClientPeg.get());
this.setState({
verifying: true,
continueDisabled: true,
@ -117,7 +117,7 @@ export class EmailAddress extends React.Component<IEmailAddressProps, IEmailAddr
private async changeBindingTangledAddBind({ bind, label, errorTitle }: Binding): Promise<void> {
const { medium, address } = this.props.email;
const task = new AddThreepid();
const task = new AddThreepid(MatrixClientPeg.get());
this.setState({
verifying: true,
continueDisabled: true,

View file

@ -82,7 +82,7 @@ export class PhoneNumber extends React.Component<IPhoneNumberProps, IPhoneNumber
try {
if (bind) {
const task = new AddThreepid();
const task = new AddThreepid(MatrixClientPeg.get());
this.setState({
verifying: true,
continueDisabled: true,
@ -118,7 +118,7 @@ export class PhoneNumber extends React.Component<IPhoneNumberProps, IPhoneNumber
private async changeBindingTangledAddBind({ bind, label, errorTitle }: Binding): Promise<void> {
const { medium, address } = this.props.msisdn;
const task = new AddThreepid();
const task = new AddThreepid(MatrixClientPeg.get());
this.setState({
verifying: true,
continueDisabled: true,

View file

@ -215,7 +215,7 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
const [shouldCreate, opts] = await modal.finished;
if (shouldCreate) {
await createRoom(opts);
await createRoom(this.context, opts);
}
return shouldCreate;
};

View file

@ -35,6 +35,7 @@ import SettingsTab from "../SettingsTab";
import { SettingsSection } from "../../shared/SettingsSection";
import SettingsSubsection, { SettingsSubsectionText } from "../../shared/SettingsSubsection";
import ExternalLink from "../../../elements/ExternalLink";
import MatrixClientContext from "../../../../../contexts/MatrixClientContext";
interface IProps {
closeSettingsFn: () => void;
@ -46,6 +47,9 @@ interface IState {
}
export default class HelpUserSettingsTab extends React.Component<IProps, IState> {
public static contextType = MatrixClientContext;
public context!: React.ContextType<typeof MatrixClientContext>;
public constructor(props: IProps) {
super(props);
@ -104,7 +108,7 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
private onStartBotChat = (): void => {
this.props.closeSettingsFn();
createRoom({
createRoom(this.context, {
dmUserId: SdkConfig.get("welcome_user_id"),
andView: true,
});