Lazy loading keys; Spotify new releases in Spotify reducer, handling duplicates bug
This commit is contained in:
@ -32,17 +32,11 @@ class DiscoverNewReleases extends React.Component{
|
||||
}
|
||||
|
||||
loadMore(){
|
||||
|
||||
// TODO: Figure out how to check for duplicated requests
|
||||
// perhaps we catch this at Spotify actions, by checking for
|
||||
// pending requests on the same URL, and invalidate the Promise?
|
||||
|
||||
this.props.spotifyActions.getMore(
|
||||
this.props.new_releases_more,
|
||||
null,
|
||||
{
|
||||
type: 'SPOTIFY_NEW_RELEASES_LOADED',
|
||||
key: null
|
||||
type: 'SPOTIFY_NEW_RELEASES_LOADED'
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -111,12 +105,11 @@ class DiscoverNewReleases extends React.Component{
|
||||
)
|
||||
}
|
||||
|
||||
var albums = []
|
||||
var albums = [];
|
||||
if (this.props.new_releases){
|
||||
for (var i = 0; i < this.props.new_releases.length; i++){
|
||||
var uri = this.props.new_releases[i]
|
||||
for (var uri of this.props.new_releases){
|
||||
if (this.props.albums.hasOwnProperty(uri)){
|
||||
albums.push(this.props.albums[uri])
|
||||
albums.push(this.props.albums[uri]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -166,9 +159,9 @@ const mapStateToProps = (state, ownProps) => {
|
||||
load_queue: state.ui.load_queue,
|
||||
artists: state.core.artists,
|
||||
albums: state.core.albums,
|
||||
new_releases: state.core.new_releases,
|
||||
new_releases_more: state.core.new_releases_more,
|
||||
new_releases_total: state.core.new_releases_total
|
||||
new_releases: state.spotify.new_releases,
|
||||
new_releases_more: state.spotify.new_releases_more,
|
||||
new_releases_total: state.spotify.new_releases_total
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -184,7 +184,7 @@ class LibraryAlbums extends React.Component{
|
||||
className="album-list"
|
||||
link_prefix={global.baseURL+"album/"} />
|
||||
<LazyLoadListener
|
||||
loadKey={total_albums}
|
||||
loadKey={this.state.limit}
|
||||
showLoader={this.state.limit < total_albums}
|
||||
loadMore={() => this.setState({limit: this.state.limit + this.state.per_page})}
|
||||
/>
|
||||
@ -197,7 +197,7 @@ class LibraryAlbums extends React.Component{
|
||||
handleContextMenu={(e,item) => this.handleContextMenu(e,item)}
|
||||
albums={albums} />
|
||||
<LazyLoadListener
|
||||
loadKey={total_albums}
|
||||
loadKey={this.state.limit}
|
||||
showLoader={this.state.limit < total_albums}
|
||||
loadMore={() => this.setState({limit: this.state.limit + this.state.per_page})}
|
||||
/>
|
||||
|
||||
@ -160,7 +160,7 @@ class LibraryArtists extends React.Component{
|
||||
className="artist-list"
|
||||
link_prefix={global.baseURL+"artist/"} />
|
||||
<LazyLoadListener
|
||||
loadKey={total_artists}
|
||||
loadKey={this.state.limit}
|
||||
showLoader={this.state.limit < total_artists}
|
||||
loadMore={() => this.loadMore()}
|
||||
/>
|
||||
@ -173,7 +173,7 @@ class LibraryArtists extends React.Component{
|
||||
handleContextMenu={(e,item) => this.handleContextMenu(e,item)}
|
||||
artists={artists} />
|
||||
<LazyLoadListener
|
||||
loadKey={total_artists}
|
||||
loadKey={this.state.limit}
|
||||
showLoader={this.state.limit < total_artists}
|
||||
loadMore={() => this.loadMore()}
|
||||
/>
|
||||
|
||||
@ -156,7 +156,7 @@ class LibraryPlaylists extends React.Component{
|
||||
className="playlist-list"
|
||||
link_prefix={global.baseURL+"playlist/"} />
|
||||
<LazyLoadListener
|
||||
loadKey="playlists"
|
||||
loadKey={this.state.limit}
|
||||
loading={this.state.limit < total_playlists}
|
||||
loadMore={() => this.setState({limit: this.state.limit + this.state.per_page})}
|
||||
/>
|
||||
@ -169,7 +169,7 @@ class LibraryPlaylists extends React.Component{
|
||||
handleContextMenu={(e,item) => this.handleContextMenu(e,item)}
|
||||
playlists={playlists} />
|
||||
<LazyLoadListener
|
||||
loadKey="playlists"
|
||||
loadKey={this.state.limit}
|
||||
loading={this.state.limit < total_playlists}
|
||||
loadMore={() => this.setState({limit: this.state.limit + this.state.per_page})}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user