Skip to content

Commit

Permalink
refactor(app): use await instead
Browse files Browse the repository at this point in the history
  • Loading branch information
rubychi committed Sep 24, 2023
1 parent 55d9fe6 commit 13e8c69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion packages/client/actions/authSignUpNSignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default function authSignUpNSignIn(presets) {
type: SET_PRESET,
payload: res.data.presets,
});
return Promise.resolve();
} catch({ response }) {
console.log(response.data.error);
}
Expand Down
13 changes: 6 additions & 7 deletions packages/client/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,15 @@ class App extends Component {
window.addEventListener('message', this.onReceiveMessage);
}

componentWillReceiveProps() {
async componentWillReceiveProps() {
const token = localStorage.getItem('token');
// Sign in upon receiving user token
if (!this.state.signIn && token) {
this.props.authSignUpNSignIn(this.props.presets).then(() => {
// Set sign in flag after received the preset data
this.setState({
signIn: true,
showSignInDialog: false,
});
await this.props.authSignUpNSignIn(this.props.presets);
// Set sign in flag after received the preset data
this.setState({
signIn: true,
showSignInDialog: false,
});
}
}
Expand Down

0 comments on commit 13e8c69

Please sign in to comment.