From 7b3c34bd129a77eaade524fa1ae458903b46dfc4 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 14 Apr 2020 16:46:02 +0200 Subject: [PATCH] use js-sdk qr code generation --- .../VerificationQREmojiOptions.js | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/components/views/verification/VerificationQREmojiOptions.js b/src/components/views/verification/VerificationQREmojiOptions.js index d72c6951fe..89b3a596d7 100644 --- a/src/components/views/verification/VerificationQREmojiOptions.js +++ b/src/components/views/verification/VerificationQREmojiOptions.js @@ -20,8 +20,8 @@ import { _t } from '../../../languageHandler'; import AccessibleButton from "../elements/AccessibleButton"; import {replaceableComponent} from "../../../utils/replaceableComponent"; import VerificationQRCode from "../elements/crypto/VerificationQRCode"; -import {VerificationRequest} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest"; import Spinner from "../elements/Spinner"; +import {SCAN_QR_CODE_METHOD} from "matrix-js-sdk/src/crypto/verification/QRCode"; @replaceableComponent("views.verification.VerificationQREmojiOptions") export default class VerificationQREmojiOptions extends React.Component { @@ -31,31 +31,17 @@ export default class VerificationQREmojiOptions extends React.Component { onStartEmoji: PropTypes.func.isRequired, }; - constructor(props) { - super(props); - - this.state = { - qrProps: null, - }; - - this._prepareQrCode(props.request); - } - - async _prepareQrCode(request: VerificationRequest) { - try { - const props = await VerificationQRCode.getPropsForRequest(request); - this.setState({qrProps: props}); - } catch (e) { - console.error(e); - // We just won't show a QR code - } - } - render() { - let qrCode =
; - if (this.state.qrProps) { - qrCode = ; + const {request} = this.props; + const showQR = request.otherPartySupportsMethod(SCAN_QR_CODE_METHOD); + + let qrCode; + if (showQR) { + qrCode = ; + } else { + qrCode =
; } + return (
{_t("Verify this session by completing one of the following:")}