From 4ca2ab11fbac3fdceac6ac8a36c07be73c7b3a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 5 Sep 2021 16:36:36 +0200 Subject: [PATCH] Convert ManualDeviceKeyVerificationDialog to TS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- ... => ManualDeviceKeyVerificationDialog.tsx} | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) rename src/components/views/dialogs/{ManualDeviceKeyVerificationDialog.js => ManualDeviceKeyVerificationDialog.tsx} (84%) diff --git a/src/components/views/dialogs/ManualDeviceKeyVerificationDialog.js b/src/components/views/dialogs/ManualDeviceKeyVerificationDialog.tsx similarity index 84% rename from src/components/views/dialogs/ManualDeviceKeyVerificationDialog.js rename to src/components/views/dialogs/ManualDeviceKeyVerificationDialog.tsx index 4387108fac..a4c989d7b5 100644 --- a/src/components/views/dialogs/ManualDeviceKeyVerificationDialog.js +++ b/src/components/views/dialogs/ManualDeviceKeyVerificationDialog.tsx @@ -19,37 +19,31 @@ limitations under the License. */ import React from 'react'; -import PropTypes from 'prop-types'; import { MatrixClientPeg } from '../../../MatrixClientPeg'; -import * as sdk from '../../../index'; import * as FormattingUtils from '../../../utils/FormattingUtils'; import { _t } from '../../../languageHandler'; import { replaceableComponent } from "../../../utils/replaceableComponent"; +import QuestionDialog from "./QuestionDialog"; +import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo"; + +interface IProps { + userId: string; + device: DeviceInfo; + onFinished: (confirmed: boolean) => void; +} @replaceableComponent("views.dialogs.ManualDeviceKeyVerificationDialog") -export default class ManualDeviceKeyVerificationDialog extends React.Component { - static propTypes = { - userId: PropTypes.string.isRequired, - device: PropTypes.object.isRequired, - onFinished: PropTypes.func.isRequired, - }; - - _onCancelClick = () => { - this.props.onFinished(false); - } - - _onLegacyFinished = (confirm) => { +export default class ManualDeviceKeyVerificationDialog extends React.Component { + private onLegacyFinished = (confirm: boolean): void => { if (confirm) { MatrixClientPeg.get().setDeviceVerified( this.props.userId, this.props.device.deviceId, true, ); } this.props.onFinished(confirm); - } - - render() { - const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + }; + public render(): JSX.Element { let text; if (MatrixClientPeg.get().getUserId() === this.props.userId) { 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")} description={body} button={_t("Verify session")} - onFinished={this._onLegacyFinished} + onFinished={this.onLegacyFinished} /> ); }