Improve refresh auth

This commit is contained in:
Gabriel Augendre 2016-04-21 01:17:57 +02:00
parent b4a0b88687
commit e09833fab8

View file

@ -240,23 +240,17 @@ var App = React.createClass({
return !(this.state.access_token == null && this.state.refresh_token == null); return !(this.state.access_token == null && this.state.refresh_token == null);
}, },
refreshAuth: function (access, refresh) { refreshAuth: function (access, refresh) {
if (access == null && refresh == null) { this.setState({
this.setState({ access_token: access,
access_token: access, refresh_token: refresh
refresh_token: refresh, });
playlists: null
}); if (!(access == null && refresh == null)) {
}
else {
this.setState({
access_token: access,
refresh_token: refresh
});
this.getPlaylists(); this.getPlaylists();
} }
}, },
componentDidMount: function () { componentDidMount: function () {
if (this.state.access_token) { if (this.isLoggedIn()) {
this.getPlaylists(); this.getPlaylists();
} }
}, },
@ -265,10 +259,10 @@ var App = React.createClass({
access_token: this.state.access_token, access_token: this.state.access_token,
refresh_token: this.state.refresh_token refresh_token: this.state.refresh_token
}; };
var content = <p>Please log in with Spotify :)</p> var content = <p>Please log in with Spotify :)</p>;
if (this.isLoggedIn()) { if (this.isLoggedIn()) {
content = ( content = (
<DuplicateFinderBox auth={auth} playlists={this.state.playlists} dups={dups}/> <DuplicateFinderBox auth={auth} playlists={this.state.playlists}/>
); );
} }