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);
},
refreshAuth: function (access, refresh) {
if (access == null && refresh == null) {
this.setState({
access_token: access,
refresh_token: refresh,
playlists: null
});
}
else {
this.setState({
access_token: access,
refresh_token: refresh
});
this.setState({
access_token: access,
refresh_token: refresh
});
if (!(access == null && refresh == null)) {
this.getPlaylists();
}
},
componentDidMount: function () {
if (this.state.access_token) {
if (this.isLoggedIn()) {
this.getPlaylists();
}
},
@ -265,10 +259,10 @@ var App = React.createClass({
access_token: this.state.access_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()) {
content = (
<DuplicateFinderBox auth={auth} playlists={this.state.playlists} dups={dups}/>
<DuplicateFinderBox auth={auth} playlists={this.state.playlists}/>
);
}