_library_started switch to indicate whether we've started loading
This commit is contained in:
@ -241,21 +241,14 @@ export default function reducer(ui = {}, action){
|
||||
return Object.assign({}, ui, { albums: albums });
|
||||
|
||||
case 'LIBRARY_ALBUMS_LOADED':
|
||||
if (!action.uris){
|
||||
return Object.assign({}, ui, {
|
||||
library_albums: null,
|
||||
library_albums_more: null,
|
||||
library_albums_total: null
|
||||
});
|
||||
}
|
||||
|
||||
var library_albums = []
|
||||
if (ui.library_albums) library_albums = Object.assign([], ui.library_albums)
|
||||
|
||||
return Object.assign({}, ui, {
|
||||
library_albums: [...library_albums, ...action.uris],
|
||||
library_albums: helpers.removeDuplicates([...library_albums, ...action.uris]),
|
||||
library_albums_more: action.more,
|
||||
library_albums_total: action.total
|
||||
library_albums_total: action.total,
|
||||
library_albums_started: true
|
||||
});
|
||||
|
||||
case 'ALBUM_LIBRARY_CHECK':
|
||||
@ -347,21 +340,14 @@ export default function reducer(ui = {}, action){
|
||||
return Object.assign({}, ui, { artists: artists });
|
||||
|
||||
case 'LIBRARY_ARTISTS_LOADED':
|
||||
if (!action.uris){
|
||||
return Object.assign({}, ui, {
|
||||
library_artists: null,
|
||||
library_artists_more: null,
|
||||
library_artists_total: null
|
||||
});
|
||||
}
|
||||
|
||||
var library_artists = []
|
||||
if (ui.library_artists) library_artists = Object.assign([], ui.library_artists)
|
||||
|
||||
return Object.assign({}, ui, {
|
||||
library_artists: [...library_artists, ...action.uris],
|
||||
library_artists: helpers.removeDuplicates([...library_artists, ...action.uris]),
|
||||
library_artists_more: action.more,
|
||||
library_artists_total: action.total
|
||||
library_artists_total: action.total,
|
||||
library_artists_started: true
|
||||
});
|
||||
|
||||
case 'ARTIST_LIBRARY_CHECK':
|
||||
@ -551,7 +537,8 @@ export default function reducer(ui = {}, action){
|
||||
library_playlists = helpers.removeDuplicates(library_playlists)
|
||||
|
||||
return Object.assign({}, ui, {
|
||||
library_playlists: library_playlists
|
||||
library_playlists: library_playlists,
|
||||
library_playlists_loaded: true
|
||||
});
|
||||
|
||||
case 'PLAYLIST_LIBRARY_CHECK':
|
||||
|
||||
@ -43,9 +43,10 @@ class App extends React.Component{
|
||||
this.props.spotifyActions.connect();
|
||||
|
||||
if (this.props.spotify_authorized){
|
||||
|
||||
// TODO: remove this so we don't tap out our API limits before we even get started
|
||||
// Perhaps fire this on demand? Context menu, playlists loading or AddToPlaylistModal
|
||||
this.props.spotifyActions.getAllLibraryPlaylists();
|
||||
this.props.spotifyActions.getLibraryAlbums();
|
||||
this.props.spotifyActions.getLibraryArtists();
|
||||
}
|
||||
|
||||
// when we navigate to a new route
|
||||
|
||||
@ -25,7 +25,9 @@ class LibraryAlbums extends React.Component{
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
if (!this.props.library_albums) this.props.spotifyActions.getLibraryAlbums();
|
||||
if (!this.props.library_albums_started){
|
||||
this.props.spotifyActions.getLibraryAlbums();
|
||||
}
|
||||
}
|
||||
|
||||
handleContextMenu(e,item){
|
||||
@ -215,6 +217,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
sort_reverse: state.ui.library_albums_sort_reverse,
|
||||
library_albums: state.ui.library_albums,
|
||||
library_albums_more: state.ui.library_albums_more,
|
||||
library_albums_started: state.ui.library_albums_started,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,9 @@ class LibraryArtists extends React.Component{
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
if (!this.props.library_artists) this.props.spotifyActions.getLibraryArtists();
|
||||
if (!this.props.library_artists_started){
|
||||
this.props.spotifyActions.getLibraryArtists();
|
||||
}
|
||||
}
|
||||
|
||||
loadMore(){
|
||||
@ -162,6 +164,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
sort_reverse: state.ui.library_artists_sort_reverse,
|
||||
library_artists: state.ui.library_artists,
|
||||
library_artists_more: state.ui.library_artists_more,
|
||||
library_artists_started: state.ui.library_artists_started,
|
||||
view: state.ui.library_artists_view
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user