Use MatrixClientPeg::safeGet in src/{stores,hooks,components/structures}/* (#10988)
This commit is contained in:
parent
707fd9ccf0
commit
dd46db4817
34 changed files with 139 additions and 130 deletions
|
@ -420,7 +420,7 @@ export default class Registration extends React.Component<IProps, IState> {
|
|||
if (!this.props.brand) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
const matrixClient = MatrixClientPeg.get();
|
||||
const matrixClient = MatrixClientPeg.safeGet();
|
||||
return matrixClient.getPushers().then(
|
||||
(resp) => {
|
||||
const pushers = resp.pushers;
|
||||
|
|
|
@ -87,7 +87,7 @@ export default class SetupEncryptionBody extends React.Component<IProps, IState>
|
|||
};
|
||||
|
||||
private onVerifyClick = (): void => {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const userId = cli.getSafeUserId();
|
||||
const requestPromise = cli.requestVerification(userId);
|
||||
|
||||
|
@ -142,7 +142,7 @@ export default class SetupEncryptionBody extends React.Component<IProps, IState>
|
|||
};
|
||||
|
||||
public render(): React.ReactNode {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const { phase, lostKeys } = this.state;
|
||||
|
||||
if (this.state.verificationRequest && cli.getUser(this.state.verificationRequest.otherUserId)) {
|
||||
|
|
|
@ -94,7 +94,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
|
|||
|
||||
this.initLogin();
|
||||
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
if (cli.isCryptoEnabled()) {
|
||||
cli.countSessionsNeedingBackup().then((remaining) => {
|
||||
this.setState({ keyBackupNeeded: remaining > 0 });
|
||||
|
@ -124,7 +124,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
|
|||
|
||||
// Note: we don't use the existing Login class because it is heavily flow-based. We don't
|
||||
// care about login flows here, unless it is the single flow we support.
|
||||
const client = MatrixClientPeg.get();
|
||||
const client = MatrixClientPeg.safeGet();
|
||||
const flows = (await client.loginFlows()).flows;
|
||||
const loginViews = flows.map((f) => STATIC_FLOWS_TO_VIEWS[f.type]);
|
||||
|
||||
|
@ -148,16 +148,17 @@ export default class SoftLogout extends React.Component<IProps, IState> {
|
|||
|
||||
this.setState({ busy: true });
|
||||
|
||||
const hsUrl = MatrixClientPeg.get().getHomeserverUrl();
|
||||
const isUrl = MatrixClientPeg.get().getIdentityServerUrl();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const hsUrl = cli.getHomeserverUrl();
|
||||
const isUrl = cli.getIdentityServerUrl();
|
||||
const loginType = "m.login.password";
|
||||
const loginParams = {
|
||||
identifier: {
|
||||
type: "m.id.user",
|
||||
user: MatrixClientPeg.get().getUserId(),
|
||||
user: cli.getUserId(),
|
||||
},
|
||||
password: this.state.password,
|
||||
device_id: MatrixClientPeg.get().getDeviceId() ?? undefined,
|
||||
device_id: cli.getDeviceId() ?? undefined,
|
||||
};
|
||||
|
||||
let credentials: IMatrixClientCreds;
|
||||
|
@ -196,11 +197,11 @@ export default class SoftLogout extends React.Component<IProps, IState> {
|
|||
return;
|
||||
}
|
||||
|
||||
const isUrl = localStorage.getItem(SSO_ID_SERVER_URL_KEY) || MatrixClientPeg.get().getIdentityServerUrl();
|
||||
const isUrl = localStorage.getItem(SSO_ID_SERVER_URL_KEY) || MatrixClientPeg.safeGet().getIdentityServerUrl();
|
||||
const loginType = "m.login.token";
|
||||
const loginParams = {
|
||||
token: this.props.realQueryParams["loginToken"],
|
||||
device_id: MatrixClientPeg.get().getDeviceId() ?? undefined,
|
||||
device_id: MatrixClientPeg.safeGet().getDeviceId() ?? undefined,
|
||||
};
|
||||
|
||||
let credentials: IMatrixClientCreds;
|
||||
|
@ -262,7 +263,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
|
|||
<div>
|
||||
{introText ? <p>{introText}</p> : null}
|
||||
<SSOButtons
|
||||
matrixClient={MatrixClientPeg.get()}
|
||||
matrixClient={MatrixClientPeg.safeGet()}
|
||||
flow={flow}
|
||||
loginType={loginType}
|
||||
fragmentAfterLogin={this.props.fragmentAfterLogin}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue