Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Avoid the use of MatrixClientPeg #10911

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/VoipUserMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import LegacyCallHandler from "./LegacyCallHandler";
import { VIRTUAL_ROOM_EVENT_TYPE } from "./call-types";
import { findDMForUser } from "./utils/dm/findDMForUser";

// Functions for mapping virtual users & rooms. Currently the only lookup
// Functions for mapping virtual users & rooms. Currently, the only lookup
// is sip virtual: there could be others in the future.

export default class VoipUserMapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,

private onResetRecoveryClick = (): void => {
this.props.onFinished(false);
accessSecretStorage(async (): Promise<void> => {}, /* forceReset = */ true);
accessSecretStorage(MatrixClientPeg.get(), async (): Promise<void> => {}, /* forceReset = */ true);
};

private onRecoveryKeyChange = (e: ChangeEvent<HTMLInputElement>): void => {
Expand Down Expand Up @@ -227,7 +227,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,
});
try {
// `accessSecretStorage` may prompt for storage access as needed.
await accessSecretStorage(async (): Promise<void> => {
await accessSecretStorage(MatrixClientPeg.get(), async (): Promise<void> => {
if (!this.state.backupInfo) return;
await MatrixClientPeg.safeGet().restoreKeyBackupWithSecretStorage(
this.state.backupInfo,
Expand Down
1 change: 1 addition & 0 deletions src/components/views/rooms/ReplyTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default class ReplyTile extends React.PureComponent<IProps> {
const { hasRenderer, isInfoMessage, isSeeingThroughMessageHiddenForModeration } = getEventDisplayInfo(
MatrixClientPeg.safeGet(),
mxEvent,
MatrixClientPeg.get(),
false /* Replies are never hidden, so this should be fine */,
);
// This shouldn't happen: the caller should check we support this type
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/settings/CrossSigningPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
} else {
// Trigger the flow to set up secure backup, which is what this will do when in
// the appropriate state.
accessSecretStorage();
accessSecretStorage(MatrixClientPeg.get());
}
};

Expand Down
6 changes: 4 additions & 2 deletions src/toasts/SetupEncryptionToast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MatrixClient } from "matrix-js-sdk/src/matrix";

import Modal from "../Modal";
import { _t } from "../languageHandler";
import DeviceListener from "../DeviceListener";
Expand Down Expand Up @@ -78,7 +80,7 @@ const onReject = (): void => {
DeviceListener.sharedInstance().dismissEncryptionSetup();
};

export const showToast = (kind: Kind): void => {
export const showToast = (client: MatrixClient, kind: Kind): void => {
if (SecurityCustomisations.setupEncryptionNeeded?.(kind)) {
return;
}
Expand All @@ -95,7 +97,7 @@ export const showToast = (kind: Kind): void => {
/* static */ true,
);
try {
await accessSecretStorage();
await accessSecretStorage(client);
} finally {
modal.close();
}
Expand Down