Show spinner whilst processing recaptcha response

The fact that we showed no feedback whilst submitting the captcha
response was causing confusion on slower connections where this
took a nontrivial amount of time.

Takes a new flag from the js-sdk that indicates whether the
request being made is a background request, presenting a spinner
appropriately.

Requires https://github.com/matrix-org/matrix-js-sdk/pull/396
pull/21833/head
David Baker 2017-03-21 18:40:41 +00:00
parent 4a29d674f8
commit ec63e18b42
2 changed files with 13 additions and 5 deletions

View File

@ -140,9 +140,9 @@ export default React.createClass({
}); });
}, },
_requestCallback: function(auth) { _requestCallback: function(auth, background) {
this.setState({ this.setState({
busy: true, busy: !background,
errorText: null, errorText: null,
stageErrorText: null, stageErrorText: null,
}); });
@ -150,9 +150,11 @@ export default React.createClass({
if (this._unmounted) { if (this._unmounted) {
return; return;
} }
if (background) {
this.setState({ this.setState({
busy: false, busy: false,
}); });
}
}); });
}, },

View File

@ -160,6 +160,7 @@ export const RecaptchaAuthEntry = React.createClass({
submitAuthDict: React.PropTypes.func.isRequired, submitAuthDict: React.PropTypes.func.isRequired,
stageParams: React.PropTypes.object.isRequired, stageParams: React.PropTypes.object.isRequired,
errorText: React.PropTypes.string, errorText: React.PropTypes.string,
busy: React.PropTypes.bool,
}, },
_onCaptchaResponse: function(response) { _onCaptchaResponse: function(response) {
@ -170,6 +171,11 @@ export const RecaptchaAuthEntry = React.createClass({
}, },
render: function() { render: function() {
if (this.props.busy) {
const Loader = sdk.getComponent("elements.Spinner");
return <Loader />;
}
const CaptchaForm = sdk.getComponent("views.login.CaptchaForm"); const CaptchaForm = sdk.getComponent("views.login.CaptchaForm");
var sitePublicKey = this.props.stageParams.public_key; var sitePublicKey = this.props.stageParams.public_key;
return ( return (