have join flow use refreshSessionWithRetry()

This commit is contained in:
Ben Wheeler 2019-12-03 21:19:14 -05:00
parent 39c32e7c5f
commit c9cbb4a1e0

View file

@ -121,13 +121,16 @@ class JoinFlow extends React.Component {
// * "birth_month": ["Ensure this value is greater than or equal to 1."]
handleRegistrationResponse (err, body, res) {
this.setState({
numAttempts: this.state.numAttempts + 1,
waiting: false
numAttempts: this.state.numAttempts + 1
}, () => {
const success = this.registrationIsSuccessful(err, body, res);
if (success) {
this.props.refreshSession();
this.setState({step: this.state.step + 1});
this.props.refreshSessionWithRetry().then(() => {
this.setState({
step: this.state.step + 1,
waiting: false
});
});
return;
}
// now we know something went wrong -- either an actual error (client-side
@ -135,7 +138,10 @@ class JoinFlow extends React.Component {
// if an actual error, prompt user to try again.
if (err || res.statusCode !== 200) {
this.setState({registrationError: {errorAllowsTryAgain: true}});
this.setState({
registrationError: {errorAllowsTryAgain: true},
waiting: false
});
return;
}
@ -164,7 +170,8 @@ class JoinFlow extends React.Component {
registrationError: {
errorAllowsTryAgain: false,
errorMsg: errorMsg
}
},
waiting: false
});
});
}
@ -283,15 +290,15 @@ JoinFlow.propTypes = {
createProjectOnComplete: PropTypes.bool,
intl: intlShape,
onCompleteRegistration: PropTypes.func,
refreshSession: PropTypes.func
refreshSessionWithRetry: PropTypes.func
};
const IntlJoinFlow = injectIntl(JoinFlow);
const mapDispatchToProps = dispatch => ({
refreshSession: () => {
dispatch(sessionActions.refreshSession());
}
refreshSessionWithRetry: () => (
dispatch(sessionActions.refreshSessionWithRetry())
)
});
// Allow incoming props to override redux-provided props. Used to mock in tests.