Remove references to VerificationRequest
(#11050)
* Update references to `VerificationRequestEvent` * Update references to `Phase` * update references to legacy `PHASE_*` constants * Replace `request.canAccept` with `canAcceptVerificationRequest` * Replace `VerificationRequest` with the interface throughout * Minor strict type fixes * Add a couple of tests
This commit is contained in:
parent
6486255f54
commit
b9b93264b6
20 changed files with 72 additions and 57 deletions
|
@ -15,13 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import {
|
||||
PHASE_REQUESTED,
|
||||
PHASE_UNSENT,
|
||||
Phase as VerificationPhase,
|
||||
VerificationRequest,
|
||||
VerificationRequestEvent,
|
||||
} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||
import { VerificationPhase, VerificationRequest, VerificationRequestEvent } from "matrix-js-sdk/src/crypto-api";
|
||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||
import { User } from "matrix-js-sdk/src/models/user";
|
||||
|
||||
|
@ -78,7 +72,11 @@ const EncryptionPanel: React.FC<IProps> = (props: IProps) => {
|
|||
}, [verificationRequestPromise]);
|
||||
const changeHandler = useCallback(() => {
|
||||
// handle transitions -> cancelled for mismatches which fire a modal instead of showing a card
|
||||
if (request && request.phase === VerificationPhase.Cancelled && MISMATCHES.includes(request.cancellationCode)) {
|
||||
if (
|
||||
request &&
|
||||
request.phase === VerificationPhase.Cancelled &&
|
||||
MISMATCHES.includes(request.cancellationCode ?? "")
|
||||
) {
|
||||
Modal.createDialog(ErrorDialog, {
|
||||
headerImage: require("../../../../res/img/e2e/warning-deprecated.svg").default,
|
||||
title: _t("Your messages are not secure"),
|
||||
|
@ -139,7 +137,8 @@ const EncryptionPanel: React.FC<IProps> = (props: IProps) => {
|
|||
|
||||
const requested: boolean =
|
||||
(!request && isRequesting) ||
|
||||
(!!request && (phase === PHASE_REQUESTED || phase === PHASE_UNSENT || phase === undefined));
|
||||
(!!request &&
|
||||
(phase === VerificationPhase.Requested || phase === VerificationPhase.Unsent || phase === undefined));
|
||||
const isSelfVerification = request ? request.isSelfVerification : member.userId === cli.getUserId();
|
||||
|
||||
if (!request || requested) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
|||
import { User } from "matrix-js-sdk/src/models/user";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||
import { VerificationRequest } from "matrix-js-sdk/src/crypto-api";
|
||||
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { CryptoEvent } from "matrix-js-sdk/src/crypto";
|
||||
|
|
|
@ -18,10 +18,10 @@ import React from "react";
|
|||
import { verificationMethods } from "matrix-js-sdk/src/crypto";
|
||||
import { SCAN_QR_CODE_METHOD } from "matrix-js-sdk/src/crypto/verification/QRCode";
|
||||
import {
|
||||
Phase,
|
||||
VerificationRequest,
|
||||
VerificationPhase as Phase,
|
||||
VerificationRequestEvent,
|
||||
} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||
} from "matrix-js-sdk/src/crypto-api";
|
||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||
import { User } from "matrix-js-sdk/src/models/user";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
@ -202,7 +202,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
};
|
||||
|
||||
private getDevice(): DeviceInfo | null {
|
||||
const deviceId = this.props.request && this.props.request.otherDeviceId;
|
||||
const deviceId = this.props.request?.otherDeviceId;
|
||||
const userId = MatrixClientPeg.get().getUserId();
|
||||
if (deviceId && userId) {
|
||||
return MatrixClientPeg.get().getStoredDevice(userId, deviceId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue