Dater; Basic grid responsive; Local formatting
This commit is contained in:
@ -95,14 +95,6 @@ export function getPlaylists(){
|
||||
return { type: 'MOPIDY_PLAYLISTS' }
|
||||
}
|
||||
|
||||
export function getBrowse( uri ){
|
||||
return {
|
||||
type: 'MOPIDY_INSTRUCT',
|
||||
call: 'library.browse',
|
||||
value: { uri: uri }
|
||||
}
|
||||
}
|
||||
|
||||
export function getPlaylist( uri ){
|
||||
return {
|
||||
type: 'MOPIDY_PLAYLIST',
|
||||
@ -110,6 +102,13 @@ export function getPlaylist( uri ){
|
||||
}
|
||||
}
|
||||
|
||||
export function getDirectory( uri ){
|
||||
return {
|
||||
type: 'MOPIDY_DIRECTORY',
|
||||
data: { uri: uri }
|
||||
}
|
||||
}
|
||||
|
||||
export function getAlbum( uri ){
|
||||
return {
|
||||
type: 'MOPIDY_ALBUM',
|
||||
@ -130,3 +129,9 @@ export function getArtists(){
|
||||
}
|
||||
}
|
||||
|
||||
export function getAlbums(){
|
||||
return {
|
||||
type: 'MOPIDY_ALBUMS'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -264,13 +264,27 @@ const MopidyMiddleware = (function(){
|
||||
})
|
||||
break;
|
||||
|
||||
case 'MOPIDY_DIRECTORY':
|
||||
store.dispatch({ type: 'MOPIDY_DIRECTORY_LOADED', data: false });
|
||||
instruct( socket, store, 'library.browse', action.data )
|
||||
.then( response => {
|
||||
store.dispatch({ type: 'MOPIDY_DIRECTORY_LOADED', data: response });
|
||||
})
|
||||
break;
|
||||
|
||||
case 'MOPIDY_ARTISTS':
|
||||
store.dispatch({ type: 'MOPIDY_ARTISTS_LOADED', data: false });
|
||||
instruct( socket, store, 'library.browse', { uri: 'local:directory?type=artist' } )
|
||||
.then( response => {
|
||||
var artists = response;
|
||||
|
||||
store.dispatch({ type: 'MOPIDY_ARTISTS_LOADED', data: artists });
|
||||
.then( response => {
|
||||
store.dispatch({ type: 'MOPIDY_ARTISTS_LOADED', data: response });
|
||||
})
|
||||
break;
|
||||
|
||||
case 'MOPIDY_ALBUMS':
|
||||
store.dispatch({ type: 'MOPIDY_ALBUMS_LOADED', data: false });
|
||||
instruct( socket, store, 'library.browse', { uri: 'local:directory?type=album' } )
|
||||
.then( response => {
|
||||
store.dispatch({ type: 'MOPIDY_ALBUMS_LOADED', data: response });
|
||||
})
|
||||
break;
|
||||
|
||||
|
||||
@ -72,9 +72,9 @@ export default function reducer(mopidy = {}, action){
|
||||
volume: action.data
|
||||
});
|
||||
|
||||
case 'MOPIDY_BROWSE':
|
||||
case 'MOPIDY_DIRECTORY_LOADED':
|
||||
return Object.assign({}, mopidy, {
|
||||
browse: action.data
|
||||
directory: action.data
|
||||
});
|
||||
|
||||
case 'MOPIDY_PLAYLIST_LOADED':
|
||||
@ -97,6 +97,11 @@ export default function reducer(mopidy = {}, action){
|
||||
artists: action.data
|
||||
});
|
||||
|
||||
case 'MOPIDY_ALBUMS_LOADED':
|
||||
return Object.assign({}, mopidy, {
|
||||
albums: action.data
|
||||
});
|
||||
|
||||
default:
|
||||
return mopidy
|
||||
}
|
||||
|
||||
@ -217,40 +217,63 @@ export function getTrack( uri ){
|
||||
* @param uri string
|
||||
**/
|
||||
export function getArtist( uri ){
|
||||
return (dispatch, getState) => {
|
||||
return (dispatch, getState) => {
|
||||
|
||||
// flush out the previous store value
|
||||
// flush out the previous store value
|
||||
dispatch({ type: 'SPOTIFY_ARTIST_LOADED', data: false });
|
||||
|
||||
var artist = {};
|
||||
var artist = {};
|
||||
|
||||
// while we're fiddling about, go get the albums
|
||||
dispatch(getArtistAlbums(uri));
|
||||
// while we're fiddling about, go get the albums
|
||||
dispatch(getArtistAlbums(uri));
|
||||
|
||||
// get both the artist and the top tracks
|
||||
$.when(
|
||||
// get both the artist and the top tracks
|
||||
$.when(
|
||||
|
||||
sendRequest( dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) )
|
||||
.then( response => {
|
||||
Object.assign(artist, response);
|
||||
}),
|
||||
sendRequest( dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) )
|
||||
.then( response => {
|
||||
Object.assign(artist, response);
|
||||
}),
|
||||
|
||||
sendRequest( dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/top-tracks?country='+getState().spotify.country )
|
||||
.then( response => {
|
||||
Object.assign(artist, response);
|
||||
}),
|
||||
|
||||
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) +'/related-artists' )
|
||||
.then( response => {
|
||||
Object.assign(artist, { related_artists: response.artists });
|
||||
})
|
||||
|
||||
).then( () => {
|
||||
).then( () => {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_ARTIST_LOADED',
|
||||
data: artist
|
||||
type: 'SPOTIFY_ARTIST_LOADED',
|
||||
data: artist
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function getArtists( uris ){
|
||||
return (dispatch, getState) => {
|
||||
|
||||
// flush out the previous store value
|
||||
dispatch({ type: 'SPOTIFY_ARTISTS_LOADED', data: false });
|
||||
|
||||
// now get all the artists for this album (full objects)
|
||||
var ids = '';
|
||||
for( var i = 0; i < uris.length; i++ ){
|
||||
if( ids != '' ) ids += ','
|
||||
ids += helpers.getFromUri( 'artistid', uris[i] );
|
||||
}
|
||||
|
||||
sendRequest( dispatch, getState, 'artists/?ids='+ids )
|
||||
.then( response => {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_ARTISTS_LOADED',
|
||||
data: response.artists
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,6 +303,13 @@ export function getAlbum( uri ){
|
||||
sendRequest( dispatch, getState, 'albums/'+ helpers.getFromUri('albumid', uri) )
|
||||
.then( response => {
|
||||
|
||||
// now get all the artists for this album (full objects)
|
||||
var artist_uris = [];
|
||||
for( var i = 0; i < response.artists.length; i++ ){
|
||||
artist_uris.push( response.artists[i].uri )
|
||||
}
|
||||
dispatch(getArtists(artist_uris));
|
||||
|
||||
// inject the parent album object into each track for consistent track objects
|
||||
for( var i = 0; i < response.tracks.items.length; i++ ){
|
||||
response.tracks.items[i].album = {
|
||||
|
||||
@ -65,6 +65,9 @@ export default function reducer(spotify = {}, action){
|
||||
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 });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user