Adding play artist top tracks, fixes #32
This commit is contained in:
@ -174,6 +174,11 @@ class ContextMenu extends React.Component{
|
||||
this.props.mopidyActions.playPlaylist(this.props.menu.uris[0])
|
||||
}
|
||||
|
||||
playArtistTopTracks(e){
|
||||
this.props.uiActions.hideContextMenu()
|
||||
this.props.spotifyActions.playArtistTopTracks(this.props.menu.uris[0])
|
||||
}
|
||||
|
||||
addToQueue(e, next = false){
|
||||
this.props.uiActions.hideContextMenu()
|
||||
this.props.mopidyActions.enqueueURIs(this.props.menu.uris, this.props.menu.tracklist_uri, next)
|
||||
@ -361,6 +366,14 @@ class ContextMenu extends React.Component{
|
||||
</span>
|
||||
)
|
||||
|
||||
var play_artist_top_tracks = (
|
||||
<span className="menu-item-wrapper">
|
||||
<a className="menu-item" onClick={e => this.playArtistTopTracks(e)}>
|
||||
<span className="label">Play top tracks</span>
|
||||
</a>
|
||||
</span>
|
||||
)
|
||||
|
||||
var add_to_queue = (
|
||||
<span className="menu-item-wrapper">
|
||||
<a className="menu-item" onClick={e => this.addToQueue(e)}>
|
||||
@ -463,6 +476,7 @@ class ContextMenu extends React.Component{
|
||||
case 'artist':
|
||||
return (
|
||||
<div>
|
||||
{context.source == 'spotify' ? play_artist_top_tracks : null}
|
||||
{start_radio}
|
||||
{context.source == 'spotify' ? go_to_recommendations : null}
|
||||
{copy_uris}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
|
||||
var uiActions = require('../../services/ui/actions')
|
||||
var mopidyActions = require('../../services/mopidy/actions')
|
||||
var lastfmActions = require('../../services/lastfm/actions')
|
||||
var helpers = require('../../helpers')
|
||||
|
||||
@ -912,6 +913,27 @@ export function getLibraryArtists(){
|
||||
}
|
||||
|
||||
|
||||
export function playArtistTopTracks(uri){
|
||||
return (dispatch, getState) => {
|
||||
const artists = getState().ui.artists
|
||||
|
||||
// Do we have this artist (and their tracks) in our index already?
|
||||
if (typeof(artists[uri]) !== 'undefined' && typeof(artists[uri].tracks) !== 'undefined'){
|
||||
const uris = helpers.asURIs(artists[uri].tracks)
|
||||
dispatch(mopidyActions.playURIs(uris, uri))
|
||||
|
||||
// We need to load the artist's top tracks first
|
||||
} else {
|
||||
sendRequest( dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/top-tracks?country='+getState().spotify.country )
|
||||
.then( response => {
|
||||
const uris = helpers.asURIs(response.tracks)
|
||||
dispatch(mopidyActions.playURIs(uris, uri))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* =============================================================== USER(S) ==============
|
||||
|
||||
@ -31,7 +31,7 @@ class Artist extends React.Component{
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
this.loadArtist();
|
||||
this.loadArtist()
|
||||
}
|
||||
|
||||
componentWillReceiveProps( nextProps ){
|
||||
|
||||
Reference in New Issue
Block a user