Convert VerificationRequestDialog

This commit is contained in:
David Baker 2021-07-01 14:22:58 +01:00
parent 16fb24fa09
commit 5d3b94b7c9
2 changed files with 25 additions and 21 deletions

View file

@ -1,5 +1,5 @@
/* /*
Copyright 2020 The Matrix.org Foundation C.I.C. Copyright 2020-2021 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,27 +15,33 @@ limitations under the License.
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { MatrixClientPeg } from '../../../MatrixClientPeg'; import { MatrixClientPeg } from '../../../MatrixClientPeg';
import * as sdk from '../../../index';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
import { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
import BaseDialog from "./BaseDialog";
import EncryptionPanel from "../right_panel/EncryptionPanel";
import { User } from 'matrix-js-sdk';
interface IProps {
verificationRequest: VerificationRequest;
verificationRequestPromise: Promise<VerificationRequest>;
onFinished: () => void;
member: User;
}
interface IState {
verificationRequest: VerificationRequest;
}
@replaceableComponent("views.dialogs.VerificationRequestDialog") @replaceableComponent("views.dialogs.VerificationRequestDialog")
export default class VerificationRequestDialog extends React.Component { export default class VerificationRequestDialog extends React.Component<IProps, IState> {
static propTypes = { constructor(props) {
verificationRequest: PropTypes.object, super(props);
verificationRequestPromise: PropTypes.object, this.state = {
onFinished: PropTypes.func.isRequired, verificationRequest: this.props.verificationRequest,
member: PropTypes.string, };
}; if (this.props.verificationRequestPromise) {
constructor(...args) {
super(...args);
this.state = {};
if (this.props.verificationRequest) {
this.state.verificationRequest = this.props.verificationRequest;
} else if (this.props.verificationRequestPromise) {
this.props.verificationRequestPromise.then(r => { this.props.verificationRequestPromise.then(r => {
this.setState({ verificationRequest: r }); this.setState({ verificationRequest: r });
}); });
@ -43,8 +49,6 @@ export default class VerificationRequestDialog extends React.Component {
} }
render() { render() {
const BaseDialog = sdk.getComponent("views.dialogs.BaseDialog");
const EncryptionPanel = sdk.getComponent("views.right_panel.EncryptionPanel");
const request = this.state.verificationRequest; const request = this.state.verificationRequest;
const otherUserId = request && request.otherUserId; const otherUserId = request && request.otherUserId;
const member = this.props.member || const member = this.props.member ||
@ -65,6 +69,7 @@ export default class VerificationRequestDialog extends React.Component {
verificationRequestPromise={this.props.verificationRequestPromise} verificationRequestPromise={this.props.verificationRequestPromise}
onClose={this.props.onFinished} onClose={this.props.onFinished}
member={member} member={member}
isRoomEncrypted={false}
/> />
</BaseDialog>; </BaseDialog>;
} }

View file

@ -16,7 +16,6 @@ limitations under the License.
import React from "react"; import React from "react";
import * as sdk from "../../../index";
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import { MatrixClientPeg } from '../../../MatrixClientPeg'; import { MatrixClientPeg } from '../../../MatrixClientPeg';
import { RightPanelPhases } from "../../../stores/RightPanelStorePhases"; import { RightPanelPhases } from "../../../stores/RightPanelStorePhases";
@ -30,6 +29,7 @@ import { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/reque
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo"; import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
import { Action } from "../../../dispatcher/actions"; import { Action } from "../../../dispatcher/actions";
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
import VerificationRequestDialog from "../dialogs/VerificationRequestDialog"
interface IProps { interface IProps {
toastKey: string; toastKey: string;
@ -123,7 +123,6 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
}, },
}); });
} else { } else {
const VerificationRequestDialog = sdk.getComponent("views.dialogs.VerificationRequestDialog");
Modal.createTrackedDialog('Incoming Verification', '', VerificationRequestDialog, { Modal.createTrackedDialog('Incoming Verification', '', VerificationRequestDialog, {
verificationRequest: request, verificationRequest: request,
onFinished: () => { onFinished: () => {