You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-28 15:22:05 +03:00
Just return the promise if it's a bg request
This makes the code a bit neater.
This commit is contained in:
@ -141,26 +141,25 @@ export default React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_requestCallback: function(auth, background) {
|
_requestCallback: function(auth, background) {
|
||||||
// only set the busy flag if this is a non-background request,
|
const makeRequestPromise = this.props.makeRequest(auth);
|
||||||
// otherwise, the user initiated a request, so make the busy
|
|
||||||
// spinner appear and clear and existing error messages.
|
// if it's a background request, just do it: we don't want
|
||||||
if (!background) {
|
// it to affect the state of our UI.
|
||||||
this.setState({
|
if (background) return makeRequestPromise;
|
||||||
busy: true,
|
|
||||||
errorText: null,
|
// otherwise, manage the state of the spinner and error messages
|
||||||
stageErrorText: null,
|
this.setState({
|
||||||
});
|
busy: true,
|
||||||
}
|
errorText: null,
|
||||||
return this.props.makeRequest(auth).finally(() => {
|
stageErrorText: null,
|
||||||
|
});
|
||||||
|
return makeRequestPromise.finally(() => {
|
||||||
if (this._unmounted) {
|
if (this._unmounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// only unset the busy flag if this is a non-background request
|
this.setState({
|
||||||
if (!background) {
|
busy: false,
|
||||||
this.setState({
|
});
|
||||||
busy: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user