Convert ManualDeviceKeyVerificationDialog to TS

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-09-05 16:36:36 +02:00
parent e80939d3e2
commit 4ca2ab11fb
No known key found for this signature in database
GPG key ID: 55C211A1226CB17D

View file

@ -19,37 +19,31 @@ 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 * as FormattingUtils from '../../../utils/FormattingUtils'; import * as FormattingUtils from '../../../utils/FormattingUtils';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
import QuestionDialog from "./QuestionDialog";
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
@replaceableComponent("views.dialogs.ManualDeviceKeyVerificationDialog") interface IProps {
export default class ManualDeviceKeyVerificationDialog extends React.Component { userId: string;
static propTypes = { device: DeviceInfo;
userId: PropTypes.string.isRequired, onFinished: (confirmed: boolean) => void;
device: PropTypes.object.isRequired,
onFinished: PropTypes.func.isRequired,
};
_onCancelClick = () => {
this.props.onFinished(false);
} }
_onLegacyFinished = (confirm) => { @replaceableComponent("views.dialogs.ManualDeviceKeyVerificationDialog")
export default class ManualDeviceKeyVerificationDialog extends React.Component<IProps> {
private onLegacyFinished = (confirm: boolean): void => {
if (confirm) { if (confirm) {
MatrixClientPeg.get().setDeviceVerified( MatrixClientPeg.get().setDeviceVerified(
this.props.userId, this.props.device.deviceId, true, this.props.userId, this.props.device.deviceId, true,
); );
} }
this.props.onFinished(confirm); this.props.onFinished(confirm);
} };
render() {
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
public render(): JSX.Element {
let text; let text;
if (MatrixClientPeg.get().getUserId() === this.props.userId) { if (MatrixClientPeg.get().getUserId() === this.props.userId) {
text = _t("Confirm by comparing the following with the User Settings in your other session:"); text = _t("Confirm by comparing the following with the User Settings in your other session:");
@ -81,7 +75,7 @@ export default class ManualDeviceKeyVerificationDialog extends React.Component {
title={_t("Verify session")} title={_t("Verify session")}
description={body} description={body}
button={_t("Verify session")} button={_t("Verify session")}
onFinished={this._onLegacyFinished} onFinished={this.onLegacyFinished}
/> />
); );
} }