Moving follow check to asset, rather than component, fixes #146
This commit is contained in:
@ -12,38 +12,32 @@ import * as spotifyActions from '../services/spotify/actions'
|
||||
class FollowButton extends React.Component{
|
||||
|
||||
constructor(props){
|
||||
super(props)
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
if (this.props.spotify_authorized && this.props.uri){
|
||||
this.props.spotifyActions.following(this.props.uri)
|
||||
}
|
||||
super(props);
|
||||
}
|
||||
|
||||
remove(){
|
||||
this.props.spotifyActions.following(this.props.uri, 'DELETE')
|
||||
this.props.spotifyActions.following(this.props.uri, 'DELETE');
|
||||
}
|
||||
|
||||
add(){
|
||||
this.props.spotifyActions.following(this.props.uri, 'PUT')
|
||||
this.props.spotifyActions.following(this.props.uri, 'PUT');
|
||||
}
|
||||
|
||||
render(){
|
||||
if (!this.props.uri){
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
var className = ''
|
||||
var className = '';
|
||||
|
||||
// Inherit passed-down classes
|
||||
if (this.props.className){
|
||||
className += ' '+this.props.className
|
||||
className += ' '+this.props.className;
|
||||
}
|
||||
|
||||
// Loader
|
||||
if (helpers.isLoading(this.props.load_queue,['/following','/followers','me/albums/contains/?ids=','me/albums/?ids='])){
|
||||
className += ' working'
|
||||
className += ' working';
|
||||
}
|
||||
|
||||
if (!this.props.spotify_authorized){
|
||||
|
||||
@ -69,6 +69,7 @@ class Album extends React.Component{
|
||||
} else {
|
||||
this.props.spotifyActions.getAlbum(props.params.uri);
|
||||
}
|
||||
this.props.spotifyActions.following(props.params.uri);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@ -35,10 +35,10 @@ class Artist extends React.Component{
|
||||
|
||||
componentWillReceiveProps(nextProps){
|
||||
if (nextProps.params.uri != this.props.params.uri){
|
||||
this.loadArtist(nextProps )
|
||||
this.loadArtist(nextProps);
|
||||
}else if (!this.props.mopidy_connected && nextProps.mopidy_connected){
|
||||
if (helpers.uriSource(this.props.params.uri ) != 'spotify'){
|
||||
this.loadArtist(nextProps )
|
||||
this.loadArtist(nextProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -50,7 +50,7 @@ class Artist extends React.Component{
|
||||
items: [this.props.artist],
|
||||
uris: [this.props.params.uri]
|
||||
}
|
||||
this.props.uiActions.showContextMenu(data)
|
||||
this.props.uiActions.showContextMenu(data);
|
||||
}
|
||||
|
||||
loadArtist(props = this.props){
|
||||
@ -58,16 +58,17 @@ class Artist extends React.Component{
|
||||
|
||||
case 'spotify':
|
||||
if (props.artist && props.artist.albums_uris && props.artist.related_artists_uris){
|
||||
console.info('Loading spotify artist from index')
|
||||
console.info('Loading spotify artist from index');
|
||||
} else {
|
||||
this.props.spotifyActions.getArtist(props.params.uri, true);
|
||||
}
|
||||
this.props.spotifyActions.following(props.params.uri);
|
||||
break
|
||||
|
||||
default:
|
||||
if (props.mopidy_connected){
|
||||
if (props.artist && props.artist.images){
|
||||
console.info('Loading local artist from index')
|
||||
console.info('Loading local artist from index');
|
||||
} else {
|
||||
this.props.mopidyActions.getArtist(props.params.uri);
|
||||
}
|
||||
|
||||
@ -60,12 +60,13 @@ class Playlist extends React.Component{
|
||||
switch (helpers.uriSource(props.params.uri)){
|
||||
|
||||
case 'spotify':
|
||||
this.props.spotifyActions.getPlaylist(props.params.uri )
|
||||
this.props.spotifyActions.getPlaylist(props.params.uri);
|
||||
this.props.spotifyActions.following(props.params.uri);
|
||||
break
|
||||
|
||||
default:
|
||||
if (props.mopidy_connected){
|
||||
this.props.mopidyActions.getPlaylist(props.params.uri )
|
||||
this.props.mopidyActions.getPlaylist(props.params.uri);
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ class Track extends React.Component{
|
||||
// if mopidy has just connected AND we're a local album, go get
|
||||
} else if (!this.props.mopidy_connected && nextProps.mopidy_connected){
|
||||
if (helpers.uriSource(this.props.params.uri ) != 'spotify'){
|
||||
this.loadTrack(nextProps )
|
||||
this.loadTrack(nextProps);
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,6 +74,7 @@ class Track extends React.Component{
|
||||
console.info('Loading track from index');
|
||||
} else {
|
||||
this.props.spotifyActions.getTrack(props.params.uri);
|
||||
this.props.spotifyActions.following(props.params.uri);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@ -27,23 +27,24 @@ class User extends React.Component{
|
||||
|
||||
componentWillReceiveProps(nextProps){
|
||||
if (nextProps.params.uri != this.props.params.uri){
|
||||
this.loadUser(nextProps )
|
||||
this.loadUser(nextProps);
|
||||
}
|
||||
}
|
||||
|
||||
loadUser(props = this.props){
|
||||
if (!props.user){
|
||||
this.props.spotifyActions.getUser(props.params.uri)
|
||||
this.props.spotifyActions.getUser(props.params.uri);
|
||||
this.props.spotifyActions.following(props.params.uri);
|
||||
}
|
||||
|
||||
// We got a user, but we haven't fetched their playlists yet
|
||||
if (props.user && !props.user.playlists_uris){
|
||||
this.props.spotifyActions.getUserPlaylists(props.params.uri)
|
||||
this.props.spotifyActions.getUserPlaylists(props.params.uri);
|
||||
}
|
||||
}
|
||||
|
||||
loadMore(){
|
||||
this.props.spotifyActions.getURL(this.props.user.playlists_more, 'SPOTIFY_USER_PLAYLISTS_LOADED', this.props.params.uri )
|
||||
this.props.spotifyActions.getURL(this.props.user.playlists_more, 'SPOTIFY_USER_PLAYLISTS_LOADED', this.props.params.uri);
|
||||
}
|
||||
|
||||
isMe(){
|
||||
@ -61,9 +62,11 @@ class User extends React.Component{
|
||||
)
|
||||
}
|
||||
|
||||
if (!this.props.user) return null
|
||||
if (!this.props.user){
|
||||
return null;
|
||||
}
|
||||
|
||||
var playlists = []
|
||||
var playlists = [];
|
||||
if (this.props.user.playlists_uris){
|
||||
for (var i = 0; i < this.props.user.playlists_uris.length; i++){
|
||||
var uri = this.props.user.playlists_uris[i]
|
||||
|
||||
Reference in New Issue
Block a user