From 818156663aa7878a412289a5ba76be7ed04dfa1e Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 24 Feb 2020 13:48:41 +0100 Subject: [PATCH] don't leak if show_sas never comes (or already came) --- src/components/views/right_panel/VerificationPanel.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/views/right_panel/VerificationPanel.js b/src/components/views/right_panel/VerificationPanel.js index 45a9b9eddb..5dd01c9f79 100644 --- a/src/components/views/right_panel/VerificationPanel.js +++ b/src/components/views/right_panel/VerificationPanel.js @@ -270,6 +270,8 @@ export default class VerificationPanel extends React.PureComponent { }; _onVerifierShowSas = (sasEvent) => { + const {request} = this.props; + request.verifier.off('show_sas', this._onVerifierShowSas); this.setState({sasEvent}); }; @@ -278,7 +280,7 @@ export default class VerificationPanel extends React.PureComponent { const hadVerifier = this._hasVerifier; this._hasVerifier = !!request.verifier; if (!hadVerifier && this._hasVerifier) { - request.verifier.once('show_sas', this._onVerifierShowSas); + request.verifier.on('show_sas', this._onVerifierShowSas); try { // on the requester side, this is also awaited in _startSAS, // but that's ok as verify should return the same promise. @@ -299,6 +301,10 @@ export default class VerificationPanel extends React.PureComponent { } componentWillUnmount() { - this.props.request.off("change", this._onRequestChange); + const {request} = this.props; + if (request.verifier) { + request.verifier.off('show_sas', this._onVerifierShowSas); + } + request.off("change", this._onRequestChange); } }