diff --git a/src/js/services/mopidy/middleware.js b/src/js/services/mopidy/middleware.js index 9c79b14c..4ea958cd 100755 --- a/src/js/services/mopidy/middleware.js +++ b/src/js/services/mopidy/middleware.js @@ -1545,6 +1545,7 @@ const MopidyMiddleware = (function(){ * ====================================================================================== **/ + /* case 'MOPIDY_GET_LIBRARY_ARTISTS': instruct(socket, store, 'library.browse', { uri: 'local:directory?type=artist' } ) .then(response => { @@ -1555,23 +1556,31 @@ const MopidyMiddleware = (function(){ store.dispatch({ type: 'ARTISTS_LOADED', artists: response - }) + }); store.dispatch({ type: 'MOPIDY_LIBRARY_ARTISTS_LOADED', uris: uris - }) + }); - }) + // TODO: Load LastFM artwork? + console.log(response); + // Get artwork for first 20 + for (var i = 0; i < response.length && i < 20; i++){ + store.dispatch(lastfmActions.getArtist(response[i].uri, response[i].name)); + } + + }); break; + */ /** * TODO: Fetch and process library artists * * We can't get specific artist artwork from Mopidy. Perhaps we fetch additional * artist metadata via LastFM? Their API limits will make this quite slow. - * + **/ case 'MOPIDY_GET_LIBRARY_ARTISTS': var last_run = store.getState().ui.processes.MOPIDY_LIBRARY_ARTISTS_PROCESSOR @@ -1579,9 +1588,9 @@ const MopidyMiddleware = (function(){ if (!last_run){ instruct(socket, store, 'library.browse', { uri: 'local:directory?type=artist' } ) .then(response => { - if (response.length <= 0) return + if (response.length <= 0) return; - var uris = helpers.arrayOf('uri',response) + var uris = helpers.arrayOf('uri',response); store.dispatch({ type: 'MOPIDY_LIBRARY_ARTISTS_LOADED', @@ -1589,7 +1598,7 @@ const MopidyMiddleware = (function(){ }); // Start our process to load the full album objects - store.dispatch(uiActions.startProcess('MOPIDY_LIBRARY_ARTISTS_PROCESSOR','Loading '+uris.length+' local artists', {uris: uris})) + store.dispatch(uiActions.startProcess('MOPIDY_LIBRARY_ARTISTS_PROCESSOR','Loading '+uris.length+' local artists', {uris: uris})); }) } else if (last_run.status == 'cancelled'){ @@ -1602,11 +1611,11 @@ const MopidyMiddleware = (function(){ case 'MOPIDY_LIBRARY_ARTISTS_PROCESSOR': if (store.getState().ui.processes['MOPIDY_LIBRARY_ARTISTS_PROCESSOR'] !== undefined){ - var processor = store.getState().ui.processes['MOPIDY_LIBRARY_ARTISTS_PROCESSOR'] + var processor = store.getState().ui.processes['MOPIDY_LIBRARY_ARTISTS_PROCESSOR']; if (processor.status == 'cancelling'){ - store.dispatch(uiActions.processCancelled('MOPIDY_LIBRARY_ARTISTS_PROCESSOR')) - return false + store.dispatch(uiActions.processCancelled('MOPIDY_LIBRARY_ARTISTS_PROCESSOR')); + return false; } } @@ -1614,15 +1623,13 @@ const MopidyMiddleware = (function(){ var uris_to_load = uris.splice(0,50) if (uris_to_load.length > 0){ - store.dispatch(uiActions.updateProcess('MOPIDY_LIBRARY_ARTISTS_PROCESSOR', 'Loading '+uris.length+' local artists', {uris: uris})) - store.dispatch(mopidyActions.getArtists(uris_to_load, {name: 'MOPIDY_LIBRARY_ARTISTS_PROCESSOR', data: {uris: uris}})) + store.dispatch(uiActions.updateProcess('MOPIDY_LIBRARY_ARTISTS_PROCESSOR', 'Loading '+uris.length+' local artists', {uris: uris})); + store.dispatch(mopidyActions.getArtists(uris_to_load, {name: 'MOPIDY_LIBRARY_ARTISTS_PROCESSOR', data: {uris: uris}})); } else { - store.dispatch(uiActions.processFinished('MOPIDY_LIBRARY_ARTISTS_PROCESSOR')) + store.dispatch(uiActions.processFinished('MOPIDY_LIBRARY_ARTISTS_PROCESSOR')); } - break - - */ + break; case 'MOPIDY_GET_ARTIST': instruct(socket, store, 'library.lookup', action.data ) @@ -1698,8 +1705,12 @@ const MopidyMiddleware = (function(){ { is_mopidy: true } - ) - artists.push(artist) + ); + artists.push(artist); + + if (!artist.images){ + store.dispatch(lastfmActions.getArtist(artist.uri, artist.name)); + } } } diff --git a/src/js/views/library/LibraryArtists.js b/src/js/views/library/LibraryArtists.js index 213fbb7d..7092cd79 100755 --- a/src/js/views/library/LibraryArtists.js +++ b/src/js/views/library/LibraryArtists.js @@ -30,11 +30,11 @@ class LibraryArtists extends React.Component{ componentDidMount(){ if (this.props.mopidy_library_artists_status != 'finished' && this.props.mopidy_connected && (this.props.source == 'all' || this.props.source == 'local')){ - this.props.mopidyActions.getLibraryArtists() + this.props.mopidyActions.getLibraryArtists(); } if (this.props.mopidy_uri_schemes.includes('spotify:') && this.props.spotify_library_artists_status != 'finished' && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')){ - this.props.spotifyActions.getLibraryArtists() + this.props.spotifyActions.getLibraryArtists(); } } @@ -43,12 +43,12 @@ class LibraryArtists extends React.Component{ // We've just connected if (!this.props.mopidy_connected){ - this.props.mopidyActions.getLibraryArtists() + this.props.mopidyActions.getLibraryArtists(); } // Filter changed, but we haven't got this provider's library yet if (this.props.source != 'all' && this.props.source != 'local' && newProps.mopidy_library_artists_status != 'finished'){ - this.props.mopidyActions.getLibraryArtists() + this.props.mopidyActions.getLibraryArtists(); } } @@ -56,12 +56,12 @@ class LibraryArtists extends React.Component{ // We've just connected if (!this.props.spotify_connected){ - this.props.spotifyActions.getLibraryArtists() + this.props.spotifyActions.getLibraryArtists(); } // Filter changed, but we haven't got this provider's library yet if (this.props.source != 'all' && this.props.source != 'spotify' && newProps.spotify_library_artists_status != 'finished'){ - this.props.spotifyActions.getLibraryArtists() + this.props.spotifyActions.getLibraryArtists(); } } } @@ -76,6 +76,11 @@ class LibraryArtists extends React.Component{ this.props.uiActions.showContextMenu(data) } + loadMore(){ + console.log('Load more') + this.setState({limit: this.state.limit + this.state.per_page}); + } + setSort(value){ var reverse = false if (this.props.sort == value ) reverse = !this.props.sort_reverse @@ -154,7 +159,7 @@ class LibraryArtists extends React.Component{ columns={columns} className="artist-list" link_prefix={global.baseURL+"artist/"} /> - this.setState({limit: this.state.limit + this.state.per_page})} /> + this.loadMore()} /> ) } else { @@ -163,7 +168,7 @@ class LibraryArtists extends React.Component{ this.handleContextMenu(e,item)} artists={artists} /> - this.setState({limit: this.state.limit + this.state.per_page})} /> + this.loadMore()} /> ) }