mirror of
https://github.com/element-hq/element-web
synced 2024-11-25 02:35:48 +03:00
don't leak if show_sas never comes (or already came)
This commit is contained in:
parent
381cbbabb0
commit
818156663a
1 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue