Users now using index

This commit is contained in:
James Barnsley
2017-01-19 08:56:12 +13:00
parent 99d27c2365
commit b611970907
5 changed files with 121 additions and 38 deletions

View File

@ -123,6 +123,16 @@ const SpotifyMiddleware = (function(){
});
break
case 'SPOTIFY_USER_FOLLOWING_LOADED':
store.dispatch({
type: 'USER_LOADED',
uri: action.uri,
user: {
is_following: action.is_following
}
});
break
case 'SPOTIFY_NEW_RELEASES_LOADED':
store.dispatch({
type: 'ALBUMS_LOADED',
@ -150,6 +160,38 @@ const SpotifyMiddleware = (function(){
});
break
case 'SPOTIFY_USER_PLAYLISTS_LOADED':
var playlists = []
for( var i = 0; i < action.data.items.length; i++ ){
var playlist = Object.assign(
{},
action.data.items[i],
{
can_edit: (store.getState().spotify.authorized && store.getState().spotify.me && action.data.items[i].owner.id == store.getState().spotify.me.id),
tracks_total: action.data.items[i].tracks.total
}
)
// remove our tracklist. It'll overwrite any full records otherwise
delete playlist.tracks
playlists.push(playlist)
}
store.dispatch({
type: 'PLAYLISTS_LOADED',
playlists: playlists
});
store.dispatch({
type: 'USER_PLAYLISTS_LOADED',
uri: action.uri,
uris: helpers.asURIs(playlists),
more: action.data.next,
total: action.data.total
});
break
case 'SPOTIFY_LIBRARY_PLAYLISTS_LOADED':
var playlists = []
for( var i = 0; i < action.playlists.length; i++ ){