From ff3c52a736abc8d1ac75fdcb3e89e5f85ebcb573 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 19 Jun 2019 14:59:59 -0600 Subject: [PATCH 1/2] Consider cancelled verifications when mounting IncomingSasDialog The cancellation can be because of a background problem, or because the user received another verification request from the same user. The cancel function does get called, however due to the speed of our dialog handling the state ends up being lost forever. Instead of trying to de-layer dialogs, this just fastforwards the whole dialog to "cancelled" on mount if required. Fixes https://github.com/vector-im/riot-web/issues/10118 --- src/components/views/dialogs/IncomingSasDialog.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/views/dialogs/IncomingSasDialog.js b/src/components/views/dialogs/IncomingSasDialog.js index da2211c10f7..5158b004f3d 100644 --- a/src/components/views/dialogs/IncomingSasDialog.js +++ b/src/components/views/dialogs/IncomingSasDialog.js @@ -46,6 +46,13 @@ export default class IncomingSasDialog extends React.Component { this._fetchOpponentProfile(); } + componentWillMount() { + if (this.props.verifier.cancelled) { + console.log("Verifier was cancelled in the background."); + this.setState({phase: PHASE_CANCELLED}); + } + } + componentWillUnmount() { if (this.state.phase !== PHASE_CANCELLED && this.state.phase !== PHASE_VERIFIED) { this.props.verifier.cancel('User cancel'); From 0f8dd102bf9707069921a89bf593a17cd6f49792 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 20 Jun 2019 14:17:06 -0600 Subject: [PATCH 2/2] Move early-cancel stuff to constructor --- src/components/views/dialogs/IncomingSasDialog.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/views/dialogs/IncomingSasDialog.js b/src/components/views/dialogs/IncomingSasDialog.js index 5158b004f3d..0720fedddcc 100644 --- a/src/components/views/dialogs/IncomingSasDialog.js +++ b/src/components/views/dialogs/IncomingSasDialog.js @@ -34,9 +34,15 @@ export default class IncomingSasDialog extends React.Component { constructor(props) { super(props); + let phase = PHASE_START; + if (this.props.verifier.cancelled) { + console.log("Verifier was cancelled in the background."); + phase = PHASE_CANCELLED; + } + this._showSasEvent = null; this.state = { - phase: PHASE_START, + phase: phase, sasVerified: false, opponentProfile: null, opponentProfileError: null, @@ -46,13 +52,6 @@ export default class IncomingSasDialog extends React.Component { this._fetchOpponentProfile(); } - componentWillMount() { - if (this.props.verifier.cancelled) { - console.log("Verifier was cancelled in the background."); - this.setState({phase: PHASE_CANCELLED}); - } - } - componentWillUnmount() { if (this.state.phase !== PHASE_CANCELLED && this.state.phase !== PHASE_VERIFIED) { this.props.verifier.cancel('User cancel');