actually start verify process in verification panel

temporary code, as ux is not complete
This commit is contained in:
Bruno Windels 2019-12-18 17:26:54 +00:00
parent c02fc44d25
commit 0f415038be

View file

@ -22,6 +22,7 @@ export default class VerificationPanel extends React.PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {}; this.state = {};
this._hasVerifier = !!props.request.verifier;
} }
render() { render() {
@ -53,12 +54,10 @@ export default class VerificationPanel extends React.PureComponent {
_startSAS = async () => { _startSAS = async () => {
const verifier = this.props.request.beginKeyVerification(verificationMethods.SAS); const verifier = this.props.request.beginKeyVerification(verificationMethods.SAS);
verifier.on('show_sas', this._onVerifierShowSas);
try { try {
await this._verifier.verify(); await verifier.verify();
} finally { } finally {
this.setState({sasEvent: null}); this.setState({sasEvent: null});
verifier.removeListener('show_sas', this._onVerifierShowSas);
} }
}; };
@ -75,6 +74,18 @@ export default class VerificationPanel extends React.PureComponent {
}; };
_onRequestChange = () => { _onRequestChange = () => {
const {request} = this.props;
if (!this._hasVerifier && !!request.verifier) {
request.verifier.on('show_sas', this._onVerifierShowSas);
try {
request.verifier.verify();
} catch (err) {
console.error("error verify", err);
}
} else if (this._hasVerifier && !request.verifier) {
request.verifier.removeListener('show_sas', this._onVerifierShowSas);
}
this._hasVerifier = !!request.verifier;
this.forceUpdate(); this.forceUpdate();
}; };