{this.renderServiceStatus('mopidy')}
{this.renderServiceStatus('pusher')}
{this.renderServiceStatus('spotify')}
+ {this.renderServiceStatus('lastfm')}
@@ -398,6 +441,7 @@ const mapDispatchToProps = (dispatch) => {
uiActions: bindActionCreators(uiActions, dispatch),
pusherActions: bindActionCreators(pusherActions, dispatch),
mopidyActions: bindActionCreators(mopidyActions, dispatch),
+ lastfmActions: bindActionCreators(lastfmActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}
diff --git a/src/js/views/Track.js b/src/js/views/Track.js
index bf5e26e6..abe477dc 100755
--- a/src/js/views/Track.js
+++ b/src/js/views/Track.js
@@ -11,6 +11,7 @@ import Thumbnail from '../components/Thumbnail'
import ArtistSentence from '../components/ArtistSentence'
import ArtistGrid from '../components/ArtistGrid'
import FollowButton from '../components/FollowButton'
+import LastfmLoveButton from '../components/LastfmLoveButton'
import Dater from '../components/Dater'
import LazyLoadListener from '../components/LazyLoadListener'
import ContextMenuTrigger from '../components/ContextMenuTrigger'
@@ -19,6 +20,7 @@ import * as helpers from '../helpers'
import * as uiActions from '../services/ui/actions'
import * as mopidyActions from '../services/mopidy/actions'
import * as spotifyActions from '../services/spotify/actions'
+import * as lastfmActions from '../services/lastfm/actions'
import * as geniusActions from '../services/genius/actions'
class Track extends React.Component{
@@ -39,20 +41,29 @@ class Track extends React.Component{
componentWillReceiveProps(nextProps){
- // if our URI has changed, fetch new album
+ // if our URI has changed, fetch new track
if (nextProps.params.uri != this.props.params.uri){
- this.loadTrack(nextProps )
+ this.loadTrack(nextProps)
- // if mopidy has just connected AND we're a local album, go get
+ // if mopidy has just connected AND we're not a Spotify track, go get
} else if (!this.props.mopidy_connected && nextProps.mopidy_connected){
- if (helpers.uriSource(this.props.params.uri ) != 'spotify'){
+ if (helpers.uriSource(this.props.params.uri) != 'spotify'){
this.loadTrack(nextProps);
}
}
- // We don't have lyrics, and we have just received our artists
- if (!nextProps.track.lyrics_results && !this.props.track.artists && nextProps.track.artists){
- this.props.geniusActions.findTrackLyrics(nextProps.track);
+ // We have just received our full track info (with artists)
+ if (!this.props.track.artists && nextProps.track.artists){
+
+ // Ready to load LastFM
+ if (nextProps.lastfm_authorized){
+ this.props.lastfmActions.getTrack(nextProps.track);
+ }
+
+ // Ready to load lyrics
+ if (!nextProps.track.lyrics_results){
+ this.props.geniusActions.findTrackLyrics(nextProps.track);
+ }
}
}
@@ -89,9 +100,18 @@ class Track extends React.Component{
break;
}
- // We don't have lyrics, but the track (and artists) is already loaded
- if (props.track && !props.track.lyrics_results && props.track.artists){
- this.props.geniusActions.findTrackLyrics(props.track);
+ // We have artist info already
+ if (props.track && props.track.artists){
+
+ // Get the LastFM version of this track (provided we have artist info)
+ if (props.lastfm_authorized){
+ this.props.lastfmActions.getTrack(props.track);
+ }
+
+ // Ready for lyrics
+ if (props.track && !props.track.lyrics_results){
+ this.props.geniusActions.findTrackLyrics(props.track);
+ }
}
}
@@ -211,7 +231,8 @@ class Track extends React.Component{
- {this.props.slim_mode ? null : this.handleContextMenu(e)} />}
+
+ this.handleContextMenu(e)} />
{this.renderLyricsSelector()}
@@ -240,6 +261,7 @@ const mapStateToProps = (state, ownProps) => {
albums: state.core.albums,
spotify_library_albums: state.spotify.library_albums,
local_library_albums: state.mopidy.library_albums,
+ lastfm_authorized: state.lastfm.session,
spotify_authorized: state.spotify.authorization,
mopidy_connected: state.mopidy.connected
};
@@ -250,6 +272,7 @@ const mapDispatchToProps = (dispatch) => {
uiActions: bindActionCreators(uiActions, dispatch),
uiActions: bindActionCreators(uiActions, dispatch),
mopidyActions: bindActionCreators(mopidyActions, dispatch),
+ lastfmActions: bindActionCreators(lastfmActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch),
geniusActions: bindActionCreators(geniusActions, dispatch)
}
diff --git a/src/js/views/User.js b/src/js/views/User.js
index 4eb26842..69b04f45 100755
--- a/src/js/views/User.js
+++ b/src/js/views/User.js
@@ -33,18 +33,20 @@ class User extends React.Component{
loadUser(props = this.props){
if (!props.user){
- this.props.spotifyActions.getUser(props.params.uri);
+ this.props.spotifyActions.getUser(props.params.uri, true);
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);
- }
}
loadMore(){
- this.props.spotifyActions.getURL(this.props.user.playlists_more, 'SPOTIFY_USER_PLAYLISTS_LOADED', this.props.params.uri);
+ this.props.spotifyActions.loadMore(
+ this.props.user.playlists_more,
+ {
+ parent_type: 'user',
+ parent_key: this.props.params.uri,
+ records_type: 'playlist'
+ }
+ );
}
isMe(){
@@ -105,7 +107,7 @@ class User extends React.Component{
Playlists
- this.loadMore() }/>
+ this.loadMore()} />
@@ -120,8 +122,7 @@ const mapStateToProps = (state, ownProps) => {
spotify_authorized: state.spotify.authorization,
me: state.spotify.me,
playlists: state.core.playlists,
- user: (state.core.users && state.core.users[uri] !== undefined ? state.core.users[uri] : false),
- users: state.core.users
+ user: (state.core.users[uri] !== undefined ? state.core.users[uri] : false)
};
}
diff --git a/src/js/views/discover/DiscoverCategory.js b/src/js/views/discover/DiscoverCategory.js
index 67a44e05..480e53f7 100755
--- a/src/js/views/discover/DiscoverCategory.js
+++ b/src/js/views/discover/DiscoverCategory.js
@@ -30,7 +30,14 @@ class DiscoverCategory extends React.Component{
}
loadMore(){
- this.props.spotifyActions.getURL(this.props.category.playlists_more, 'SPOTIFY_CATEGORY_PLAYLISTS_LOADED', 'category:'+this.props.params.id );
+ this.props.spotifyActions.loadMore(
+ this.props.category.playlists_more,
+ null,
+ {
+ type: 'SPOTIFY_CATEGORY_PLAYLISTS_LOADED',
+ key: 'category:'+this.props.params.id
+ }
+ );
}
render(){
diff --git a/src/js/views/discover/DiscoverNewReleases.js b/src/js/views/discover/DiscoverNewReleases.js
index 866f275e..831d59e4 100755
--- a/src/js/views/discover/DiscoverNewReleases.js
+++ b/src/js/views/discover/DiscoverNewReleases.js
@@ -27,7 +27,14 @@ class DiscoverNewReleases extends React.Component{
}
loadMore(){
- this.props.spotifyActions.getURL(this.props.new_releases_more, 'SPOTIFY_NEW_RELEASES_LOADED');
+ this.props.spotifyActions.loadMore(
+ this.props.new_releases_more,
+ null,
+ {
+ type: 'SPOTIFY_NEW_RELEASES_LOADED',
+ key: null
+ }
+ );
}
playAlbum(e,album){