Use MatrixClientPeg::safeGet in src/components/views/* (#10987)
This commit is contained in:
parent
4243847f4f
commit
280f6a9d93
81 changed files with 265 additions and 250 deletions
|
@ -75,7 +75,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
|||
joinRule = JoinRule.Restricted;
|
||||
}
|
||||
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
this.state = {
|
||||
isPublic: this.props.defaultPublic || false,
|
||||
isEncrypted: this.props.defaultEncrypted ?? privateShouldBeEncrypted(cli),
|
||||
|
@ -222,7 +222,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
|||
|
||||
let aliasField: JSX.Element | undefined;
|
||||
if (this.state.joinRule === JoinRule.Public) {
|
||||
const domain = MatrixClientPeg.get().getDomain()!;
|
||||
const domain = MatrixClientPeg.safeGet().getDomain()!;
|
||||
aliasField = (
|
||||
<div className="mx_CreateRoomDialog_aliasContainer">
|
||||
<RoomAliasField
|
||||
|
@ -285,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(MatrixClientPeg.get())) {
|
||||
if (privateShouldBeEncrypted(MatrixClientPeg.safeGet())) {
|
||||
if (this.state.canChangeEncryption) {
|
||||
microcopy = isVideoRoom
|
||||
? _t("You can't disable this later. The room will be encrypted but the embedded call will not.")
|
||||
|
|
|
@ -125,7 +125,7 @@ export default class DeactivateAccountDialog extends React.Component<IProps, ISt
|
|||
// XXX: this should be returning a promise to maintain the state inside the state machine correct
|
||||
// but given that a deactivation is followed by a local logout and all object instances being thrown away
|
||||
// this isn't done.
|
||||
MatrixClientPeg.get()
|
||||
MatrixClientPeg.safeGet()
|
||||
.deactivateAccount(auth, this.state.shouldErase)
|
||||
.then((r) => {
|
||||
// Deactivation worked - logout & close this dialog
|
||||
|
@ -158,7 +158,7 @@ export default class DeactivateAccountDialog extends React.Component<IProps, ISt
|
|||
}
|
||||
|
||||
private initAuth(shouldErase: boolean): void {
|
||||
MatrixClientPeg.get()
|
||||
MatrixClientPeg.safeGet()
|
||||
.deactivateAccount(null, shouldErase)
|
||||
.then((r) => {
|
||||
// If we got here, oops. The server didn't require any auth.
|
||||
|
@ -190,7 +190,7 @@ export default class DeactivateAccountDialog extends React.Component<IProps, ISt
|
|||
<div>
|
||||
{this.state.bodyText}
|
||||
<InteractiveAuth
|
||||
matrixClient={MatrixClientPeg.get()}
|
||||
matrixClient={MatrixClientPeg.safeGet()}
|
||||
authData={this.state.authData}
|
||||
// XXX: onUIAuthComplete breaches the expected method contract, it gets away with it because it
|
||||
// knows the entire app is about to die as a result of the account deactivation.
|
||||
|
|
|
@ -86,7 +86,7 @@ export default class IncomingSasDialog extends React.Component<IProps, IState> {
|
|||
|
||||
private async fetchOpponentProfile(): Promise<void> {
|
||||
try {
|
||||
const prof = await MatrixClientPeg.get().getProfileInfo(this.props.verifier.userId);
|
||||
const prof = await MatrixClientPeg.safeGet().getProfileInfo(this.props.verifier.userId);
|
||||
this.setState({
|
||||
opponentProfile: prof,
|
||||
});
|
||||
|
@ -143,7 +143,7 @@ export default class IncomingSasDialog extends React.Component<IProps, IState> {
|
|||
};
|
||||
|
||||
private renderPhaseStart(): ReactNode {
|
||||
const isSelf = this.props.verifier.userId === MatrixClientPeg.get().getUserId();
|
||||
const isSelf = this.props.verifier.userId === MatrixClientPeg.safeGet().getUserId();
|
||||
|
||||
let profile;
|
||||
const oppProfile = this.state.opponentProfile;
|
||||
|
@ -233,7 +233,7 @@ export default class IncomingSasDialog extends React.Component<IProps, IState> {
|
|||
sas={this.showSasEvent.sas}
|
||||
onCancel={this.onCancelClick}
|
||||
onDone={this.onSasMatchesClick}
|
||||
isSelf={this.props.verifier.userId === MatrixClientPeg.get().getUserId()}
|
||||
isSelf={this.props.verifier.userId === MatrixClientPeg.safeGet().getUserId()}
|
||||
inDialog={true}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -373,12 +373,12 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
|
||||
this.profilesStore = SdkContextClass.instance.userProfilesStore;
|
||||
|
||||
const alreadyInvited = new Set([MatrixClientPeg.get().getUserId()!]);
|
||||
const alreadyInvited = new Set([MatrixClientPeg.safeGet().getUserId()!]);
|
||||
const welcomeUserId = SdkConfig.get("welcome_user_id");
|
||||
if (welcomeUserId) alreadyInvited.add(welcomeUserId);
|
||||
|
||||
if (isRoomInvite(props)) {
|
||||
const room = MatrixClientPeg.get().getRoom(props.roomId);
|
||||
const room = MatrixClientPeg.safeGet().getRoom(props.roomId);
|
||||
if (!room) throw new Error("Room ID given to InviteDialog does not look like a room");
|
||||
room.getMembersWithMembership("invite").forEach((m) => alreadyInvited.add(m.userId));
|
||||
room.getMembersWithMembership("join").forEach((m) => alreadyInvited.add(m.userId));
|
||||
|
@ -395,7 +395,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
numSuggestionsShown: INITIAL_ROOMS_SHOWN,
|
||||
serverResultsMixin: [],
|
||||
threepidResultsMixin: [],
|
||||
canUseIdentityServer: !!MatrixClientPeg.get().getIdentityServerUrl(),
|
||||
canUseIdentityServer: !!MatrixClientPeg.safeGet().getIdentityServerUrl(),
|
||||
tryingIdentityServer: false,
|
||||
consultFirst: false,
|
||||
dialPadValue: "",
|
||||
|
@ -407,7 +407,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
this.encryptionByDefault = privateShouldBeEncrypted(MatrixClientPeg.get());
|
||||
this.encryptionByDefault = privateShouldBeEncrypted(MatrixClientPeg.safeGet());
|
||||
|
||||
if (this.props.initialText) {
|
||||
this.updateSuggestions(this.props.initialText);
|
||||
|
@ -428,7 +428,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
// Also pull in all the rooms tagged as DefaultTagID.DM so we don't miss anything. Sometimes the
|
||||
// room list doesn't tag the room for the DMRoomMap, but does for the room list.
|
||||
const dmTaggedRooms = RoomListStore.instance.orderedLists[DefaultTagID.DM] || [];
|
||||
const myUserId = MatrixClientPeg.get().getUserId();
|
||||
const myUserId = MatrixClientPeg.safeGet().getUserId();
|
||||
for (const dmRoom of dmTaggedRooms) {
|
||||
const otherMembers = dmRoom.getJoinedMembers().filter((u) => u.userId !== myUserId);
|
||||
for (const member of otherMembers) {
|
||||
|
@ -491,7 +491,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
}
|
||||
|
||||
private buildSuggestions(excludedTargetIds: Set<string>): { userId: string; user: Member }[] {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const activityScores = buildActivityScores(cli);
|
||||
const memberScores = buildMemberScores(cli);
|
||||
|
||||
|
@ -560,7 +560,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
this.setBusy(true);
|
||||
|
||||
try {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const targets = this.convertFilter();
|
||||
await startDmOnFirstMessage(cli, targets);
|
||||
this.props.onFinished(true);
|
||||
|
@ -601,7 +601,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
const targets = this.convertFilter();
|
||||
const targetIds = targets.map((t) => t.userId);
|
||||
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const room = cli.getRoom(this.props.roomId);
|
||||
if (!room) {
|
||||
logger.error("Failed to find the room to invite users to");
|
||||
|
@ -694,7 +694,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
};
|
||||
|
||||
private updateSuggestions = async (term: string): Promise<void> => {
|
||||
MatrixClientPeg.get()
|
||||
MatrixClientPeg.safeGet()
|
||||
.searchUserDirectory({ term })
|
||||
.then(async (r): Promise<void> => {
|
||||
if (term !== this.state.filterText) {
|
||||
|
@ -774,7 +774,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
|
||||
if (term !== this.state.filterText) return; // abandon hope
|
||||
|
||||
const lookup = await MatrixClientPeg.get().lookupThreePid("email", term, token);
|
||||
const lookup = await MatrixClientPeg.safeGet().lookupThreePid("email", term, token);
|
||||
if (term !== this.state.filterText) return; // abandon hope
|
||||
|
||||
if (!lookup || !lookup.mxid) {
|
||||
|
@ -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(MatrixClientPeg.get());
|
||||
setToDefaultIdentityServer(MatrixClientPeg.safeGet());
|
||||
this.setState({ canUseIdentityServer: true, tryingIdentityServer: false });
|
||||
};
|
||||
|
||||
|
@ -1289,7 +1289,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
const hasSelection =
|
||||
this.state.targets.length > 0 || (this.state.filterText && this.state.filterText.includes("@"));
|
||||
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const userId = cli.getUserId()!;
|
||||
if (this.props.kind === InviteKind.Dm) {
|
||||
title = _t("Direct Messages");
|
||||
|
@ -1332,11 +1332,11 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||
<p>{_t("If you can't see who you're looking for, send them your invite link below.")}</p>
|
||||
</div>
|
||||
);
|
||||
const link = makeUserPermalink(MatrixClientPeg.get().getUserId()!);
|
||||
const link = makeUserPermalink(MatrixClientPeg.safeGet().getSafeUserId());
|
||||
footer = (
|
||||
<div className="mx_InviteDialog_footer">
|
||||
<h3>{_t("Or send invite link")}</h3>
|
||||
<CopyableText getTextToCopy={() => makeUserPermalink(MatrixClientPeg.get().getUserId()!)}>
|
||||
<CopyableText getTextToCopy={() => makeUserPermalink(MatrixClientPeg.safeGet().getSafeUserId())}>
|
||||
<a className="mx_InviteDialog_footer_link" href={link} onClick={this.onLinkClick}>
|
||||
{link}
|
||||
</a>
|
||||
|
|
|
@ -50,7 +50,7 @@ export default class LogoutDialog extends React.Component<IProps, IState> {
|
|||
public constructor(props: IProps) {
|
||||
super(props);
|
||||
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const shouldLoadBackupStatus = cli.isCryptoEnabled() && !cli.getKeyBackupEnabled();
|
||||
|
||||
this.state = {
|
||||
|
@ -66,7 +66,7 @@ export default class LogoutDialog extends React.Component<IProps, IState> {
|
|||
|
||||
private async loadBackupStatus(): Promise<void> {
|
||||
try {
|
||||
const backupInfo = await MatrixClientPeg.get().getKeyBackupVersion();
|
||||
const backupInfo = await MatrixClientPeg.safeGet().getKeyBackupVersion();
|
||||
this.setState({
|
||||
loading: false,
|
||||
backupInfo,
|
||||
|
@ -86,7 +86,7 @@ export default class LogoutDialog extends React.Component<IProps, IState> {
|
|||
typeof ExportE2eKeysDialog
|
||||
>,
|
||||
{
|
||||
matrixClient: MatrixClientPeg.get(),
|
||||
matrixClient: MatrixClientPeg.safeGet(),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
|
|
@ -67,7 +67,7 @@ export default class MessageEditHistoryDialog extends React.PureComponent<IProps
|
|||
const opts = { from: this.state.nextBatch ?? undefined };
|
||||
const roomId = this.props.mxEvent.getRoomId()!;
|
||||
const eventId = this.props.mxEvent.getId()!;
|
||||
const client = MatrixClientPeg.get();
|
||||
const client = MatrixClientPeg.safeGet();
|
||||
|
||||
const { resolve, reject, promise } = defer<boolean>();
|
||||
let result: Awaited<ReturnType<MatrixClient["relations"]>>;
|
||||
|
@ -102,7 +102,7 @@ export default class MessageEditHistoryDialog extends React.PureComponent<IProps
|
|||
|
||||
private locallyRedactEventsIfNeeded(newEvents: MatrixEvent[]): void {
|
||||
const roomId = this.props.mxEvent.getRoomId();
|
||||
const client = MatrixClientPeg.get();
|
||||
const client = MatrixClientPeg.safeGet();
|
||||
const room = client.getRoom(roomId);
|
||||
if (!room) return;
|
||||
const pendingEvents = room.getPendingEvents();
|
||||
|
|
|
@ -71,7 +71,7 @@ export default class ModalWidgetDialog extends React.PureComponent<IProps, IStat
|
|||
|
||||
this.widget = new ElementWidget({
|
||||
...this.props.widgetDefinition,
|
||||
creatorUserId: MatrixClientPeg.get().getSafeUserId(),
|
||||
creatorUserId: MatrixClientPeg.safeGet().getSafeUserId(),
|
||||
id: `modal_${this.props.sourceWidgetId}`,
|
||||
});
|
||||
this.possibleButtons = (this.props.widgetDefinition.buttons || []).map((b) => b.id);
|
||||
|
@ -130,7 +130,7 @@ export default class ModalWidgetDialog extends React.PureComponent<IProps, IStat
|
|||
public render(): React.ReactNode {
|
||||
const templated = this.widget.getCompleteUrl({
|
||||
widgetRoomId: this.props.widgetRoomId,
|
||||
currentUserId: MatrixClientPeg.get().getSafeUserId(),
|
||||
currentUserId: MatrixClientPeg.safeGet().getSafeUserId(),
|
||||
userDisplayName: OwnProfileStore.instance.displayName ?? undefined,
|
||||
userHttpAvatarUrl: OwnProfileStore.instance.getHttpAvatarUrl() ?? undefined,
|
||||
clientId: ELEMENT_CLIENT_ID,
|
||||
|
|
|
@ -107,7 +107,7 @@ export default class ReportEventDialog extends React.Component<IProps, IState> {
|
|||
// Does the room support it, too?
|
||||
|
||||
// Extract state events to determine whether we should display
|
||||
const client = MatrixClientPeg.get();
|
||||
const client = MatrixClientPeg.safeGet();
|
||||
const room = client.getRoom(props.mxEvent.getRoomId());
|
||||
|
||||
for (const stateEventType of MODERATED_BY_STATE_EVENT_TYPE) {
|
||||
|
@ -237,7 +237,7 @@ export default class ReportEventDialog extends React.Component<IProps, IState> {
|
|||
});
|
||||
|
||||
try {
|
||||
const client = MatrixClientPeg.get();
|
||||
const client = MatrixClientPeg.safeGet();
|
||||
const ev = this.props.mxEvent;
|
||||
if (this.moderation && this.state.nature !== NonStandardValue.Admin) {
|
||||
const nature = this.state.nature;
|
||||
|
@ -312,7 +312,7 @@ export default class ReportEventDialog extends React.Component<IProps, IState> {
|
|||
if (this.moderation) {
|
||||
// Display report-to-moderator dialog.
|
||||
// We let the user pick a nature.
|
||||
const client = MatrixClientPeg.get();
|
||||
const client = MatrixClientPeg.safeGet();
|
||||
const homeServerName = SdkConfig.get("validated_server_config")!.hsName;
|
||||
let subtitle: string;
|
||||
switch (this.state.nature) {
|
||||
|
|
|
@ -73,7 +73,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
|
||||
public componentDidMount(): void {
|
||||
this.dispatcherRef = dis.register(this.onAction);
|
||||
MatrixClientPeg.get().on(RoomEvent.Name, this.onRoomName);
|
||||
MatrixClientPeg.safeGet().on(RoomEvent.Name, this.onRoomName);
|
||||
this.onRoomName();
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
dis.unregister(this.dispatcherRef);
|
||||
}
|
||||
|
||||
MatrixClientPeg.get().removeListener(RoomEvent.Name, this.onRoomName);
|
||||
MatrixClientPeg.get()?.removeListener(RoomEvent.Name, this.onRoomName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,7 +98,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
* @throws when room is not found
|
||||
*/
|
||||
private getRoom(): Room {
|
||||
const room = MatrixClientPeg.get().getRoom(this.props.roomId)!;
|
||||
const room = MatrixClientPeg.safeGet().getRoom(this.props.roomId)!;
|
||||
|
||||
// something is really wrong if we encounter this
|
||||
if (!room) {
|
||||
|
|
|
@ -60,7 +60,7 @@ export default class RoomUpgradeWarningDialog extends React.Component<IProps, IS
|
|||
public constructor(props: IProps) {
|
||||
super(props);
|
||||
|
||||
const room = MatrixClientPeg.get().getRoom(this.props.roomId);
|
||||
const room = MatrixClientPeg.safeGet().getRoom(this.props.roomId);
|
||||
const joinRules = room?.currentState.getStateEvents(EventType.RoomJoinRules, "");
|
||||
this.isPrivate = joinRules?.getContent()["join_rule"] !== JoinRule.Public ?? true;
|
||||
this.currentVersion = room?.getVersion();
|
||||
|
|
|
@ -72,7 +72,7 @@ export default class SetEmailDialog extends React.Component<IProps, IState> {
|
|||
});
|
||||
return;
|
||||
}
|
||||
this.addThreepid = new AddThreepid(MatrixClientPeg.get());
|
||||
this.addThreepid = new AddThreepid(MatrixClientPeg.safeGet());
|
||||
this.addThreepid.addEmailAddress(emailAddress).then(
|
||||
() => {
|
||||
Modal.createDialog(QuestionDialog, {
|
||||
|
|
|
@ -63,7 +63,7 @@ async function proxyHealthCheck(endpoint: string, hsUrl?: string): Promise<void>
|
|||
}
|
||||
|
||||
export const SlidingSyncOptionsDialog: React.FC<{ onFinished(enabled: boolean): void }> = ({ onFinished }) => {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const currentProxy = SettingsStore.getValue("feature_sliding_sync_proxy_url");
|
||||
const hasNativeSupport = useAsyncMemo(
|
||||
() =>
|
||||
|
@ -87,7 +87,7 @@ export const SlidingSyncOptionsDialog: React.FC<{ onFinished(enabled: boolean):
|
|||
const validProxy = withValidation<undefined, { error?: Error }>({
|
||||
async deriveData({ value }): Promise<{ error?: Error }> {
|
||||
try {
|
||||
await proxyHealthCheck(value!, MatrixClientPeg.get().baseUrl);
|
||||
await proxyHealthCheck(value!, MatrixClientPeg.safeGet().baseUrl);
|
||||
return {};
|
||||
} catch (error) {
|
||||
return { error };
|
||||
|
|
|
@ -34,7 +34,7 @@ const UntrustedDeviceDialog: React.FC<IProps> = ({ device, user, onFinished }) =
|
|||
let askToVerifyText: string;
|
||||
let newSessionText: string;
|
||||
|
||||
if (MatrixClientPeg.get().getUserId() === user.userId) {
|
||||
if (MatrixClientPeg.safeGet().getUserId() === user.userId) {
|
||||
newSessionText = _t("You signed in to a new session without verifying it:");
|
||||
askToVerifyText = _t("Verify your other session using one of the options below.");
|
||||
} else {
|
||||
|
|
|
@ -48,7 +48,7 @@ export default class VerificationRequestDialog extends React.Component<IProps, I
|
|||
public render(): React.ReactNode {
|
||||
const request = this.state.verificationRequest;
|
||||
const otherUserId = request?.otherUserId;
|
||||
const member = this.props.member || (otherUserId ? MatrixClientPeg.get().getUser(otherUserId) : null);
|
||||
const member = this.props.member || (otherUserId ? MatrixClientPeg.safeGet().getUser(otherUserId) : null);
|
||||
const title = request?.isSelfVerification ? _t("Verify other device") : _t("Verification Request");
|
||||
|
||||
if (!member) return null;
|
||||
|
|
|
@ -107,7 +107,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
|
|||
}
|
||||
|
||||
try {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const decodedKey = cli.keyBackupKeyFromRecoveryKey(this.state.recoveryKey);
|
||||
const correct = await cli.checkSecretStorageKey(decodedKey, this.props.keyInfo);
|
||||
this.setState({
|
||||
|
@ -235,7 +235,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
|
|||
// Force reset secret storage (which resets the key backup)
|
||||
await accessSecretStorage(async (): Promise<void> => {
|
||||
// Now reset cross-signing so everything Just Works™ again.
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
await cli.bootstrapCrossSigning({
|
||||
authUploadDeviceSigningKeys: async (makeRequest): Promise<void> => {
|
||||
const { finished } = Modal.createDialog(InteractiveAuthDialog, {
|
||||
|
|
|
@ -73,7 +73,7 @@ export default class CreateCrossSigningDialog extends React.PureComponent<IProps
|
|||
|
||||
private async queryKeyUploadAuth(): Promise<void> {
|
||||
try {
|
||||
await MatrixClientPeg.get().uploadDeviceSigningKeys(undefined, {} as CrossSigningKeys);
|
||||
await MatrixClientPeg.safeGet().uploadDeviceSigningKeys(undefined, {} as CrossSigningKeys);
|
||||
// We should never get here: the server should always require
|
||||
// UI auth to upload device signing keys. If we do, we upload
|
||||
// no keys which would be a no-op.
|
||||
|
@ -98,11 +98,11 @@ export default class CreateCrossSigningDialog extends React.PureComponent<IProps
|
|||
type: "m.login.password",
|
||||
identifier: {
|
||||
type: "m.id.user",
|
||||
user: MatrixClientPeg.get().getUserId(),
|
||||
user: MatrixClientPeg.safeGet().getUserId(),
|
||||
},
|
||||
// TODO: Remove `user` once servers support proper UIA
|
||||
// See https://github.com/matrix-org/synapse/issues/5665
|
||||
user: MatrixClientPeg.get().getUserId(),
|
||||
user: MatrixClientPeg.safeGet().getUserId(),
|
||||
password: this.state.accountPassword,
|
||||
});
|
||||
} else if (this.props.tokenLogin) {
|
||||
|
@ -126,7 +126,7 @@ export default class CreateCrossSigningDialog extends React.PureComponent<IProps
|
|||
|
||||
const { finished } = Modal.createDialog(InteractiveAuthDialog, {
|
||||
title: _t("Setting up keys"),
|
||||
matrixClient: MatrixClientPeg.get(),
|
||||
matrixClient: MatrixClientPeg.safeGet(),
|
||||
makeRequest,
|
||||
aestheticsForStagePhases: {
|
||||
[SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics,
|
||||
|
@ -145,9 +145,8 @@ export default class CreateCrossSigningDialog extends React.PureComponent<IProps
|
|||
error: null,
|
||||
});
|
||||
|
||||
const cli = MatrixClientPeg.get();
|
||||
|
||||
try {
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
await cli.bootstrapCrossSigning({
|
||||
authUploadDeviceSigningKeys: this.doBootstrapUIAuth,
|
||||
});
|
||||
|
|
|
@ -131,7 +131,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,
|
|||
private onRecoveryKeyChange = (e: ChangeEvent<HTMLInputElement>): void => {
|
||||
this.setState({
|
||||
recoveryKey: e.target.value,
|
||||
recoveryKeyValid: MatrixClientPeg.get().isValidRecoveryKey(e.target.value),
|
||||
recoveryKeyValid: MatrixClientPeg.safeGet().isValidRecoveryKey(e.target.value),
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -145,7 +145,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,
|
|||
try {
|
||||
// We do still restore the key backup: we must ensure that the key backup key
|
||||
// is the right one and restoring it is currently the only way we can do this.
|
||||
const recoverInfo = await MatrixClientPeg.get().restoreKeyBackupWithPassword(
|
||||
const recoverInfo = await MatrixClientPeg.safeGet().restoreKeyBackupWithPassword(
|
||||
this.state.passPhrase,
|
||||
undefined,
|
||||
undefined,
|
||||
|
@ -153,7 +153,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,
|
|||
{ progressCallback: this.progressCallback },
|
||||
);
|
||||
if (this.props.keyCallback) {
|
||||
const key = await MatrixClientPeg.get().keyBackupKeyFromPassword(
|
||||
const key = await MatrixClientPeg.safeGet().keyBackupKeyFromPassword(
|
||||
this.state.passPhrase,
|
||||
this.state.backupInfo,
|
||||
);
|
||||
|
@ -186,7 +186,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,
|
|||
restoreType: RestoreType.RecoveryKey,
|
||||
});
|
||||
try {
|
||||
const recoverInfo = await MatrixClientPeg.get().restoreKeyBackupWithRecoveryKey(
|
||||
const recoverInfo = await MatrixClientPeg.safeGet().restoreKeyBackupWithRecoveryKey(
|
||||
this.state.recoveryKey,
|
||||
undefined,
|
||||
undefined,
|
||||
|
@ -194,7 +194,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,
|
|||
{ progressCallback: this.progressCallback },
|
||||
);
|
||||
if (this.props.keyCallback) {
|
||||
const key = MatrixClientPeg.get().keyBackupKeyFromRecoveryKey(this.state.recoveryKey);
|
||||
const key = MatrixClientPeg.safeGet().keyBackupKeyFromRecoveryKey(this.state.recoveryKey);
|
||||
this.props.keyCallback(key);
|
||||
}
|
||||
if (!this.props.showSummary) {
|
||||
|
@ -230,7 +230,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,
|
|||
// `accessSecretStorage` may prompt for storage access as needed.
|
||||
await accessSecretStorage(async (): Promise<void> => {
|
||||
if (!this.state.backupInfo) return;
|
||||
await MatrixClientPeg.get().restoreKeyBackupWithSecretStorage(
|
||||
await MatrixClientPeg.safeGet().restoreKeyBackupWithSecretStorage(
|
||||
this.state.backupInfo,
|
||||
undefined,
|
||||
undefined,
|
||||
|
@ -252,7 +252,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,
|
|||
private async restoreWithCachedKey(backupInfo: IKeyBackupInfo | null): Promise<boolean> {
|
||||
if (!backupInfo) return false;
|
||||
try {
|
||||
const recoverInfo = await MatrixClientPeg.get().restoreKeyBackupWithCache(
|
||||
const recoverInfo = await MatrixClientPeg.safeGet().restoreKeyBackupWithCache(
|
||||
undefined /* targetRoomId */,
|
||||
undefined /* targetSessionId */,
|
||||
backupInfo,
|
||||
|
@ -274,7 +274,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,
|
|||
loadError: null,
|
||||
});
|
||||
try {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const backupInfo = await cli.getKeyBackupVersion();
|
||||
const has4S = await cli.hasSecretStorageKey();
|
||||
const backupKeyStored = has4S ? await cli.isKeyBackupKeyStored() : null;
|
||||
|
|
|
@ -171,7 +171,7 @@ const toPublicRoomResult = (publicRoom: IPublicRoomsChunkRoom): IPublicRoomResul
|
|||
});
|
||||
|
||||
const toRoomResult = (room: Room): IRoomResult => {
|
||||
const myUserId = MatrixClientPeg.get().getUserId();
|
||||
const myUserId = MatrixClientPeg.safeGet().getUserId();
|
||||
const otherUserId = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
|
||||
|
||||
if (otherUserId) {
|
||||
|
@ -281,7 +281,7 @@ interface IDirectoryOpts {
|
|||
const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = null, onFinished }) => {
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
||||
const cli = MatrixClientPeg.get();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const rovingContext = useContext(RovingTabIndexContext);
|
||||
const [query, _setQuery] = useState(initialText);
|
||||
const [recentSearches, clearRecentSearches] = useRecentSearches();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue