From cab95f43ff4048ef8e37f91a86ee378df5d950f5 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 10 Aug 2016 18:58:36 +0100 Subject: [PATCH] Show cancel button whilst inviting is in progress And make it actually cancel the process. --- src/components/views/dialogs/MultiInviteDialog.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/components/views/dialogs/MultiInviteDialog.js b/src/components/views/dialogs/MultiInviteDialog.js index 1e8b8bc96a..62b66c6de9 100644 --- a/src/components/views/dialogs/MultiInviteDialog.js +++ b/src/components/views/dialogs/MultiInviteDialog.js @@ -25,6 +25,7 @@ export default class MultiInviteDialog extends React.Component { this._onCancel = this._onCancel.bind(this); this._startInviting = this._startInviting.bind(this); + this._canceled = false; this.state = { busy: false, @@ -41,7 +42,12 @@ export default class MultiInviteDialog extends React.Component { } } + componentWillUnmount() { + this._unmounted = true; + } + _onCancel() { + this._canceled = true; this.props.onFinished(false); } @@ -54,6 +60,10 @@ export default class MultiInviteDialog extends React.Component { } _inviteMore(nextIndex) { + if (this._canceled) { + return; + } + if (nextIndex == this.props.inputs.length) { this.setState({ busy: false, @@ -80,12 +90,16 @@ export default class MultiInviteDialog extends React.Component { } inviteToRoom(this.props.roomId, input).then(() => { + if (this._unmounted) { return; } + this.setState((s) => { s.completionStates[nextIndex] = 'invited' return s; }); this._inviteMore(nextIndex + 1); }, (err) => { + if (this._unmounted) { return; } + let errorText; let fatal = false; if (err.errcode == 'M_FORBIDDEN') { @@ -155,6 +169,7 @@ export default class MultiInviteDialog extends React.Component { let controls = []; if (this.state.busy) { controls.push(); + controls.push(); controls.push({this._getProgressIndicator()}); } else if (this.state.done) { controls.push(