Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Show spinner whilst processing recaptcha response #767

Merged
merged 4 commits into from
Mar 22, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/components/structures/InteractiveAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,25 @@ export default React.createClass({
});
},

_requestCallback: function(auth) {
this.setState({
busy: true,
errorText: null,
stageErrorText: null,
});
_requestCallback: function(auth, background) {
// only set the busy flag if this is a non-background request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, I'm still not grokking it. A comment that says "do X" doesn't help me understand why X is the right thing to do :/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any better?

if (!background) {
this.setState({
busy: true,
errorText: null,
stageErrorText: null,
});
}
return this.props.makeRequest(auth).finally(() => {
if (this._unmounted) {
return;
}
this.setState({
busy: false,
});
// only unset the busy flag if this is a non-background request
if (!background) {
this.setState({
busy: false,
});
}
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export const RecaptchaAuthEntry = React.createClass({
submitAuthDict: React.PropTypes.func.isRequired,
stageParams: React.PropTypes.object.isRequired,
errorText: React.PropTypes.string,
busy: React.PropTypes.bool,
},

_onCaptchaResponse: function(response) {
Expand All @@ -170,6 +171,11 @@ export const RecaptchaAuthEntry = React.createClass({
},

render: function() {
if (this.props.busy) {
const Loader = sdk.getComponent("elements.Spinner");
return <Loader />;
}

const CaptchaForm = sdk.getComponent("views.login.CaptchaForm");
var sitePublicKey = this.props.stageParams.public_key;
return (
Expand Down