Playlist loader; Logging; Mopidy search

This commit is contained in:
James Barnsley
2016-11-07 18:09:42 +13:00
parent 5aec62a296
commit 757f11a6dd
12 changed files with 334 additions and 204 deletions

View File

@ -138,6 +138,8 @@ export function connect(){
dispatch({ type: 'SPOTIFY_CONNECTING' });
// send a generic request to ensure spotify is up and running
// there is no 'test' or 'ping' endpoint on the Spotify API
sendRequest( dispatch, getState, 'browse/categories?limit=1' )
.then( response => {
dispatch({

View File

@ -61,9 +61,29 @@ export default function reducer(spotify = {}, action){
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_ALBUM_LOADED':
return Object.assign({}, spotify, { album: action.data });
case 'SPOTIFY_ALBUM_LOADED_MORE':
var album = spotify.album
Object.assign(album, { tracks: {
href: action.data.href,
next: action.data.next,
previous: action.data.previous,
items: [ ...spotify.album.tracks.items, ...action.data.items ]
}})
return Object.assign({}, spotify, { album: album });
case 'SPOTIFY_ARTIST_LOADED':
return Object.assign({}, spotify, { artist: action.data });