/* Copyright 2019 Vector Creations Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import React from 'react'; import PropTypes from 'prop-types'; import { _t, _tSasV1 } from '../../../languageHandler'; import {PendingActionSpinner} from "../right_panel/EncryptionInfo"; import AccessibleButton from "../elements/AccessibleButton"; import DialogButtons from "../elements/DialogButtons"; import { fixupColorFonts } from '../../../utils/FontManager'; export default class VerificationShowSas extends React.Component { static propTypes = { pending: PropTypes.bool, displayName: PropTypes.string, // required if pending is true device: PropTypes.object, onDone: PropTypes.func.isRequired, onCancel: PropTypes.func.isRequired, sas: PropTypes.object.isRequired, isSelf: PropTypes.bool, inDialog: PropTypes.bool, // whether this component is being shown in a dialog and to use DialogButtons }; constructor(props) { super(props); this.state = { pending: false, }; } componentWillMount() { // As this component is also used before login (during complete security), // also make sure we have a working emoji font to display the SAS emojis here. // This is also done from LoggedInView. fixupColorFonts(); } onMatchClick = () => { this.setState({ pending: true }); this.props.onDone(); }; onDontMatchClick = () => { this.setState({ cancelling: true }); this.props.onCancel(); }; render() { let sasDisplay; let sasCaption; if (this.props.sas.emoji) { const emojiBlocks = this.props.sas.emoji.map( (emoji, i) =>
{sasCaption}
{sasDisplay}{this.props.isSelf ? "": _t("To be secure, do this in person or use a trusted way to communicate.")}
{confirm}