Show cancel button whilst inviting is in progress
And make it actually cancel the process.pull/21833/head
parent
d6f7358f81
commit
cab95f43ff
|
@ -25,6 +25,7 @@ export default class MultiInviteDialog extends React.Component {
|
||||||
|
|
||||||
this._onCancel = this._onCancel.bind(this);
|
this._onCancel = this._onCancel.bind(this);
|
||||||
this._startInviting = this._startInviting.bind(this);
|
this._startInviting = this._startInviting.bind(this);
|
||||||
|
this._canceled = false;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
busy: false,
|
busy: false,
|
||||||
|
@ -41,7 +42,12 @@ export default class MultiInviteDialog extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this._unmounted = true;
|
||||||
|
}
|
||||||
|
|
||||||
_onCancel() {
|
_onCancel() {
|
||||||
|
this._canceled = true;
|
||||||
this.props.onFinished(false);
|
this.props.onFinished(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +60,10 @@ export default class MultiInviteDialog extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
_inviteMore(nextIndex) {
|
_inviteMore(nextIndex) {
|
||||||
|
if (this._canceled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (nextIndex == this.props.inputs.length) {
|
if (nextIndex == this.props.inputs.length) {
|
||||||
this.setState({
|
this.setState({
|
||||||
busy: false,
|
busy: false,
|
||||||
|
@ -80,12 +90,16 @@ export default class MultiInviteDialog extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
inviteToRoom(this.props.roomId, input).then(() => {
|
inviteToRoom(this.props.roomId, input).then(() => {
|
||||||
|
if (this._unmounted) { return; }
|
||||||
|
|
||||||
this.setState((s) => {
|
this.setState((s) => {
|
||||||
s.completionStates[nextIndex] = 'invited'
|
s.completionStates[nextIndex] = 'invited'
|
||||||
return s;
|
return s;
|
||||||
});
|
});
|
||||||
this._inviteMore(nextIndex + 1);
|
this._inviteMore(nextIndex + 1);
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
|
if (this._unmounted) { return; }
|
||||||
|
|
||||||
let errorText;
|
let errorText;
|
||||||
let fatal = false;
|
let fatal = false;
|
||||||
if (err.errcode == 'M_FORBIDDEN') {
|
if (err.errcode == 'M_FORBIDDEN') {
|
||||||
|
@ -155,6 +169,7 @@ export default class MultiInviteDialog extends React.Component {
|
||||||
let controls = [];
|
let controls = [];
|
||||||
if (this.state.busy) {
|
if (this.state.busy) {
|
||||||
controls.push(<Spinner key="spinner" />);
|
controls.push(<Spinner key="spinner" />);
|
||||||
|
controls.push(<button key="cancel" onClick={this._onCancel}>Cancel</button>);
|
||||||
controls.push(<span key="progr">{this._getProgressIndicator()}</span>);
|
controls.push(<span key="progr">{this._getProgressIndicator()}</span>);
|
||||||
} else if (this.state.done) {
|
} else if (this.state.done) {
|
||||||
controls.push(
|
controls.push(
|
||||||
|
|
Loading…
Reference in New Issue