import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import FontAwesome from 'react-fontawesome' import Thumbnail from '../components/Thumbnail' import PlaylistGrid from '../components/PlaylistGrid' import FollowButton from '../components/FollowButton' import LazyLoadListener from '../components/LazyLoadListener' import SidebarToggleButton from '../components/SidebarToggleButton' import Parallax from '../components/Parallax' import ContextMenuTrigger from '../components/ContextMenuTrigger' import * as helpers from '../helpers' import * as mopidyActions from '../services/mopidy/actions' import * as spotifyActions from '../services/spotify/actions' class User extends React.Component{ constructor(props){ super(props); } componentDidMount(){ this.loadUser(); } componentWillReceiveProps(nextProps){ if (nextProps.params.uri != this.props.params.uri){ this.loadUser(nextProps ) } } loadUser(props = this.props){ if (!props.user){ this.props.spotifyActions.getUser(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) } } loadMore(){ this.props.spotifyActions.getURL(this.props.user.playlists_more, 'SPOTIFY_USER_PLAYLISTS_LOADED', this.props.params.uri ) } isMe(){ let userid = helpers.getFromUri('userid',this.props.params.uri); return (this.props.me && this.props.me.id && this.props.me.id == userid); } render(){ var user_id = helpers.getFromUri('userid',this.props.params.uri) if (helpers.isLoading(this.props.load_queue,['spotify_users/'+user_id,'spotify_users/'+user_id+'/playlists/?'])){ return (