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

Commit

Permalink
Update references to QrCodeEvent, SasEvent and VerificationEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed May 25, 2023
1 parent a5f5759 commit 34908c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
13 changes: 6 additions & 7 deletions src/components/views/dialogs/IncomingSasDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ limitations under the License.
*/

import React, { ReactNode } from "react";
import { SasEvent } from "matrix-js-sdk/src/crypto/verification/SAS";
import { VerificationBase, VerificationEvent } from "matrix-js-sdk/src/crypto/verification/Base";
import { GeneratedSas, ShowSasCallbacks } from "matrix-js-sdk/src/crypto-api/verification";
import { VerificationBase } from "matrix-js-sdk/src/crypto/verification/Base";
import { GeneratedSas, ShowSasCallbacks, VerifierEvent } from "matrix-js-sdk/src/crypto-api/verification";
import { logger } from "matrix-js-sdk/src/logger";

import { MatrixClientPeg } from "../../../MatrixClientPeg";
Expand All @@ -38,7 +37,7 @@ const PHASE_VERIFIED = 3;
const PHASE_CANCELLED = 4;

interface IProps {
verifier: VerificationBase<SasEvent, any>;
verifier: VerificationBase<VerifierEvent, any>;
onFinished(verified?: boolean): void;
}

Expand Down Expand Up @@ -74,16 +73,16 @@ export default class IncomingSasDialog extends React.Component<IProps, IState> {
opponentProfileError: null,
sas: null,
};
this.props.verifier.on(SasEvent.ShowSas, this.onVerifierShowSas);
this.props.verifier.on(VerificationEvent.Cancel, this.onVerifierCancel);
this.props.verifier.on(VerifierEvent.ShowSas, this.onVerifierShowSas);
this.props.verifier.on(VerifierEvent.Cancel, this.onVerifierCancel);
this.fetchOpponentProfile();
}

public componentWillUnmount(): void {
if (this.state.phase !== PHASE_CANCELLED && this.state.phase !== PHASE_VERIFIED) {
this.props.verifier.cancel(new Error("User cancel"));
}
this.props.verifier.removeListener(SasEvent.ShowSas, this.onVerifierShowSas);
this.props.verifier.removeListener(VerifierEvent.ShowSas, this.onVerifierShowSas);
}

private async fetchOpponentProfile(): Promise<void> {
Expand Down
18 changes: 9 additions & 9 deletions src/components/views/right_panel/VerificationPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ limitations under the License.

import React from "react";
import { verificationMethods } from "matrix-js-sdk/src/crypto";
import { QrCodeEvent, ReciprocateQRCode, SCAN_QR_CODE_METHOD } from "matrix-js-sdk/src/crypto/verification/QRCode";
import { ReciprocateQRCode, SCAN_QR_CODE_METHOD } from "matrix-js-sdk/src/crypto/verification/QRCode";
import {
Phase,
VerificationRequest,
VerificationRequestEvent,
} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
import { User } from "matrix-js-sdk/src/models/user";
import { SAS, SasEvent } from "matrix-js-sdk/src/crypto/verification/SAS";
import { SAS } from "matrix-js-sdk/src/crypto/verification/SAS";
import { logger } from "matrix-js-sdk/src/logger";
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
import { ShowQrCodeCallbacks, ShowSasCallbacks } from "matrix-js-sdk/src/crypto-api/verification";
import { ShowQrCodeCallbacks, ShowSasCallbacks, VerifierEvent } from "matrix-js-sdk/src/crypto-api/verification";

import { MatrixClientPeg } from "../../../MatrixClientPeg";
import VerificationQRCode from "../elements/crypto/VerificationQRCode";
Expand Down Expand Up @@ -402,8 +402,8 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
const { request } = this.props;
const sasEvent = (request.verifier as SAS).sasEvent;
const reciprocateQREvent = (request.verifier as ReciprocateQRCode).reciprocateQREvent;
request.verifier?.off(SasEvent.ShowSas, this.updateVerifierState);
request.verifier?.off(QrCodeEvent.ShowReciprocateQr, this.updateVerifierState);
request.verifier?.off(VerifierEvent.ShowSas, this.updateVerifierState);
request.verifier?.off(VerifierEvent.ShowReciprocateQr, this.updateVerifierState);
this.setState({ sasEvent, reciprocateQREvent });
};

Expand All @@ -412,8 +412,8 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
const hadVerifier = this.hasVerifier;
this.hasVerifier = !!request.verifier;
if (!hadVerifier && this.hasVerifier) {
request.verifier?.on(SasEvent.ShowSas, this.updateVerifierState);
request.verifier?.on(QrCodeEvent.ShowReciprocateQr, this.updateVerifierState);
request.verifier?.on(VerifierEvent.ShowSas, this.updateVerifierState);
request.verifier?.on(VerifierEvent.ShowReciprocateQr, this.updateVerifierState);
try {
// on the requester side, this is also awaited in startSAS,
// but that's ok as verify should return the same promise.
Expand All @@ -438,8 +438,8 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
public componentWillUnmount(): void {
const { request } = this.props;
if (request.verifier) {
request.verifier.off(SasEvent.ShowSas, this.updateVerifierState);
request.verifier.off(QrCodeEvent.ShowReciprocateQr, this.updateVerifierState);
request.verifier.off(VerifierEvent.ShowSas, this.updateVerifierState);
request.verifier.off(VerifierEvent.ShowReciprocateQr, this.updateVerifierState);
}
request.off(VerificationRequestEvent.Change, this.onRequestChange);
}
Expand Down

0 comments on commit 34908c0

Please sign in to comment.