Artist and Playlist
This commit is contained in:
@ -231,9 +231,6 @@ export function getArtist( uri ){
|
||||
|
||||
var artist = {};
|
||||
|
||||
// while we're fiddling about, go get the albums
|
||||
dispatch(getArtistAlbums(uri));
|
||||
|
||||
// get both the artist and the top tracks
|
||||
$.when(
|
||||
|
||||
@ -250,6 +247,11 @@ export function getArtist( uri ){
|
||||
sendRequest( dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/related-artists' )
|
||||
.then( response => {
|
||||
Object.assign(artist, { related_artists: response.artists });
|
||||
}),
|
||||
|
||||
sendRequest( dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/albums' )
|
||||
.then( response => {
|
||||
Object.assign(artist, { albums: response.items, albums_more: response.next });
|
||||
})
|
||||
|
||||
).then( () => {
|
||||
@ -284,18 +286,6 @@ export function getArtists( uris ){
|
||||
}
|
||||
}
|
||||
|
||||
export function getArtistAlbums( uri ){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest( dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/albums' )
|
||||
.then( response => {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_ARTIST_ALBUMS_LOADED',
|
||||
data: response
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Single album
|
||||
*
|
||||
|
||||
@ -55,36 +55,9 @@ export default function reducer(spotify = {}, action){
|
||||
case 'SPOTIFY_ME_LOADED':
|
||||
return Object.assign({}, spotify, { me: action.data });
|
||||
|
||||
case 'SPOTIFY_PLAYLIST_LOADED':
|
||||
return Object.assign({}, spotify, { playlist: action.data });
|
||||
|
||||
case 'SPOTIFY_PLAYLIST_LOADED_MORE':
|
||||
var playlist = spotify.playlist
|
||||
Object.assign(playlist, { tracks: {
|
||||
href: action.data.href,
|
||||
next: action.data.next,
|
||||
previous: action.data.previous,
|
||||
items: [ ...spotify.playlist.tracks.items, ...action.data.items ]
|
||||
}})
|
||||
return Object.assign({}, spotify, { playlist: playlist });
|
||||
|
||||
case 'SPOTIFY_ARTIST_LOADED':
|
||||
return Object.assign({}, spotify, { artist: action.data });
|
||||
|
||||
case 'SPOTIFY_ARTISTS_LOADED':
|
||||
return Object.assign({}, spotify, { artists: action.data });
|
||||
|
||||
case 'SPOTIFY_ARTIST_ALBUMS_LOADED':
|
||||
return Object.assign({}, spotify, { artist_albums: action.data });
|
||||
|
||||
case 'SPOTIFY_ARTIST_ALBUMS_LOADED_MORE':
|
||||
return Object.assign({}, spotify, { artist_albums: {
|
||||
href: action.data.href,
|
||||
next: action.data.next,
|
||||
previous: action.data.previous,
|
||||
items: [ ...spotify.artist_albums.items, ...action.data.items ]
|
||||
}});
|
||||
|
||||
case 'SPOTIFY_LIBRARY_PLAYLISTS_LOADED':
|
||||
return Object.assign({}, spotify, { library_playlists: action.data });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user