Rebuild of touch and click events on tracks

This commit is contained in:
James Barnsley
2017-07-22 06:36:47 +12:00
parent 52ce953c29
commit 48b32a4a5d
8 changed files with 332 additions and 255 deletions

View File

@ -286,7 +286,7 @@ const MopidyMiddleware = (function(){
if (typeof(response.tracks) === 'undefined'){
store.dispatch(uiActions.createNotification('Failed to load playlist tracks','bad'))
} else {
var tracks_uris = helpers.asURIs(response.tracks)
var tracks_uris = helpers.arrayOf('uri',response.tracks)
store.dispatch(mopidyActions.playURIs(tracks_uris, action.uri))
}
})
@ -582,7 +582,7 @@ const MopidyMiddleware = (function(){
.then( response => {
// drop in our URI list
var playlist_uris = helpers.asURIs(response)
var playlist_uris = helpers.arrayOf('uri',response)
store.dispatch({ type: 'LIBRARY_PLAYLISTS_LOADED', uris: playlist_uris });
@ -645,7 +645,7 @@ const MopidyMiddleware = (function(){
case 'MOPIDY_RESOLVE_PLAYLIST_TRACKS':
var tracks = Object.assign([], action.tracks)
var uris = helpers.asURIs(tracks)
var uris = helpers.arrayOf('uri',tracks)
instruct( socket, store, 'library.lookup', { uris: uris } )
.then( response => {
@ -839,7 +839,7 @@ const MopidyMiddleware = (function(){
.then( response => {
if (response.length <= 0) return
var uris = helpers.asURIs(response)
var uris = helpers.arrayOf('uri',response)
store.dispatch({
type: 'MOPIDY_GET_ALBUMS',
@ -964,7 +964,7 @@ const MopidyMiddleware = (function(){
});
store.dispatch({
type: 'LOCAL_ARTISTS_LOADED',
uris: helpers.asURIs(response)
uris: helpers.arrayOf('uri',response)
});
})
break;
@ -999,7 +999,7 @@ const MopidyMiddleware = (function(){
(response ? response[0].artists[0] : {}),
{
is_mopidy: true,
albums_uris: helpers.asURIs(albums),
albums_uris: helpers.arrayOf('uri',albums),
tracks: response.slice(0,10)
}
)

View File

@ -334,7 +334,7 @@ export function getFeaturedPlaylists(){
type: 'SPOTIFY_FEATURED_PLAYLISTS_LOADED',
data: {
message: response.message,
playlists: helpers.asURIs(response.playlists.items)
playlists: helpers.arrayOf('uri',response.playlists.items)
}
});
});
@ -471,11 +471,11 @@ export function getSearchResults(query, type = 'album,artist,playlist,track', li
dispatch({
type: 'SEARCH_RESULTS_LOADED',
playlists_uris: helpers.asURIs(playlists),
playlists_uris: helpers.arrayOf('uri',playlists),
playlists_more: response.playlists.next,
artists_uris: helpers.asURIs(response.artists.items),
artists_uris: helpers.arrayOf('uri',response.artists.items),
artists_more: response.artists.next,
albums_uris: helpers.asURIs(response.albums.items),
albums_uris: helpers.arrayOf('uri',response.albums.items),
albums_more: response.albums.next,
tracks: response.tracks.items,
tracks_more: response.tracks.next
@ -765,7 +765,7 @@ export function getRecommendations(uris = [], limit = 20){
seeds_uris: uris,
tracks: response.tracks,
artists_uris: artists_uris,
albums_uris: helpers.asURIs(albums)
albums_uris: helpers.arrayOf('uri',albums)
})
})
}
@ -833,7 +833,7 @@ export function getArtist(uri, full = false){
type: 'ARTISTS_LOADED',
artists: response.artists
});
Object.assign(artist, { related_artists_uris: helpers.asURIs(response.artists) });
Object.assign(artist, { related_artists_uris: helpers.arrayOf('uri',response.artists) });
})
)
}
@ -888,7 +888,7 @@ export function getArtists( uris ){
album: artist.albums[i]
});
}
artist.albums = helpers.asURIs(artist.albums)
artist.albums = helpers.arrayOf('uri',artist.albums)
artist.albums_more = artist.albums.next
dispatch({
type: 'ARTIST_LOADED',
@ -919,14 +919,14 @@ export function playArtistTopTracks(uri){
// 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)
const uris = helpers.arrayOf('uri',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)
const uris = helpers.arrayOf('uri',response.tracks)
dispatch(mopidyActions.playURIs(uris, uri))
})
}
@ -1013,7 +1013,7 @@ export function getAlbum( uri ){
{},
response,
{
artists_uris: helpers.asURIs(response.artists),
artists_uris: helpers.arrayOf('uri',response.artists),
tracks: response.tracks.items,
tracks_more: response.tracks.next,
tracks_total: response.tracks.total

View File

@ -94,7 +94,7 @@ const SpotifyMiddleware = (function(){
});
store.dispatch({
type: 'NEW_RELEASES_LOADED',
uris: helpers.asURIs(action.data.albums.items),
uris: helpers.arrayOf('uri',action.data.albums.items),
more: action.data.albums.next,
total: action.data.albums.total
});
@ -108,7 +108,7 @@ const SpotifyMiddleware = (function(){
store.dispatch({
type: 'ARTIST_ALBUMS_LOADED',
key: action.key,
uris: helpers.asURIs(action.data.items),
uris: helpers.arrayOf('uri',action.data.items),
more: action.data.next,
total: action.data.total
});
@ -139,7 +139,7 @@ const SpotifyMiddleware = (function(){
store.dispatch({
type: 'USER_PLAYLISTS_LOADED',
key: action.key,
uris: helpers.asURIs(playlists),
uris: helpers.arrayOf('uri',playlists),
more: action.data.next,
total: action.data.total
});
@ -170,7 +170,7 @@ const SpotifyMiddleware = (function(){
store.dispatch({
type: 'CATEGORY_PLAYLISTS_LOADED',
key: action.key,
uris: helpers.asURIs(playlists),
uris: helpers.arrayOf('uri',playlists),
more: action.data.playlists.next,
total: action.data.playlists.total
});
@ -202,7 +202,7 @@ const SpotifyMiddleware = (function(){
store.dispatch({
type: 'LIBRARY_PLAYLISTS_LOADED',
uris: helpers.asURIs(playlists)
uris: helpers.arrayOf('uri',playlists)
});
break
@ -225,7 +225,7 @@ const SpotifyMiddleware = (function(){
});
store.dispatch({
type: 'LIBRARY_ARTISTS_LOADED',
uris: helpers.asURIs(artists),
uris: helpers.arrayOf('uri',artists),
more: action.data.artists.next,
total: action.data.artists.total
});
@ -256,7 +256,7 @@ const SpotifyMiddleware = (function(){
store.dispatch({
type: 'LIBRARY_ALBUMS_LOADED',
uris: helpers.asURIs(albums),
uris: helpers.arrayOf('uri',albums),
more: action.data.next,
total: action.data.total
});
@ -268,14 +268,14 @@ const SpotifyMiddleware = (function(){
type: 'ARTISTS_LOADED',
artists: action.artists
})
action.artists_uris = helpers.asURIs(action.artists)
action.artists_uris = helpers.arrayOf('uri',action.artists)
}
if (action.tracks.length > 0){
store.dispatch({
type: 'TRACKS_LOADED',
tracks: action.tracks
})
action.tracks_uris = helpers.asURIs(action.tracks)
action.tracks_uris = helpers.arrayOf('uri',action.tracks)
}
next(action)
break
@ -305,7 +305,7 @@ const SpotifyMiddleware = (function(){
store.dispatch({
type: 'SEARCH_RESULTS_LOADED',
playlists_uris: helpers.asURIs(action.data.playlists.items),
playlists_uris: helpers.arrayOf('uri',action.data.playlists.items),
playlists_more: action.data.playlists.next
});
break
@ -319,7 +319,7 @@ const SpotifyMiddleware = (function(){
store.dispatch({
type: 'SEARCH_RESULTS_LOADED',
albums_uris: helpers.asURIs(action.data.albums.items),
albums_uris: helpers.arrayOf('uri',action.data.albums.items),
albums_more: action.data.albums.next
});
break
@ -344,7 +344,7 @@ const SpotifyMiddleware = (function(){
store.dispatch({
type: 'SEARCH_RESULTS_LOADED',
playlists_uris: helpers.asURIs(action.data.playlists.items),
playlists_uris: helpers.arrayOf('uri',action.data.playlists.items),
playlists_more: action.data.playlists.next
});
break