Unpaginated local albums merged into library.albums

This commit is contained in:
James Barnsley
2017-08-08 21:34:52 +12:00
parent ba97a6be4a
commit 184ba5547c
7 changed files with 43 additions and 30 deletions

View File

@ -49,12 +49,12 @@ class AlbumGrid extends React.Component{
onClick={ (e) => this.handleClick(e,global.baseURL+'album/'+album.uri) }
onContextMenu={e => this.handleContextMenu(e,album)}>
<Thumbnail size="medium" images={album.images} />
<div className="name">
{album.name ? <div className="name">
{album.name}
{this.props.show_source_icon ? <FontAwesome name={helpers.sourceIcon(album.uri)} className="source" fixedWidth /> : null}
</div>
</div> : <div className="name dark-grey-text">{album.uri}</div>}
<div className="secondary">
{album.artists ? <ArtistSentence artists={album.artists} /> : <span>-</span>}
{album.artists ? <ArtistSentence artists={album.artists} /> : null}
</div>
</div>
)

View File

@ -206,9 +206,9 @@ export default function reducer(core = {}, action){
return Object.assign({}, core, {
library_albums: helpers.removeDuplicates([...library_albums, ...action.uris]),
library_albums_spotify_more: (action.spotify_more ? action.spotify_more : null),
library_albums_more: (action.more ? action.more : null),
library_albums_total: (action.total ? action.total : null),
library_albums_spotify_started: (action.spotify_started ? action.spotify_started : null),
library_albums_started: (action.started ? action.started : null),
});
case 'ALBUM_LIBRARY_CHECK':

View File

@ -844,7 +844,7 @@ const MopidyMiddleware = (function(){
store.dispatch({
type: 'MOPIDY_GET_ALBUMS',
uris: uris.slice(0,50)
uris: uris//.slice(0,50) THIS PAGINATES REQUESTS. Slow servers might need this...
});
store.dispatch({

View File

@ -85,9 +85,10 @@ export default function reducer(spotify = {}, action){
}
))
}
console.log(action)
return Object.assign({}, spotify, {
library_albums: albums,
library_albums_more: action.data.next
library_albums_spotify_more: action.data.next
})
case 'SPOTIFY_LIBRARY_ALBUMS_LOADED_MORE':
@ -103,7 +104,7 @@ export default function reducer(spotify = {}, action){
}
return Object.assign({}, spotify, {
library_albums: [...spotify.library_albums, ...albums ],
library_albums_more: action.data.next
library_albums_spotify_more: action.data.next
})
case 'SPOTIFY_LIBRARY_TRACKS_LOADED':

View File

@ -35,8 +35,9 @@ class LibraryAlbums extends React.Component{
}
componentWillReceiveProps(newProps){
if (!this.props.spotify_connected && newProps.spotify_connected && !this.props.library_albums_spotify_started){
if (!this.props.spotify_connected && newProps.spotify_connected && !this.props.library_albums_started){
this.props.spotifyActions.getLibraryAlbums()
console.log('getting')
}
if (!this.props.mopidy_connected && newProps.mopidy_connected && !newProps.local_albums){
@ -72,7 +73,7 @@ class LibraryAlbums extends React.Component{
}
loadMoreSpotify(){
this.props.spotifyActions.getURL( this.props.library_albums_spotify_more, 'SPOTIFY_LIBRARY_ALBUMS_LOADED' );
this.props.spotifyActions.getURL( this.props.library_albums_more, 'SPOTIFY_LIBRARY_ALBUMS_LOADED' );
}
loadMoreMopidy(){
@ -163,27 +164,35 @@ class LibraryAlbums extends React.Component{
var albums = []
if (this.props.library_albums && this.props.albums){
for (var i = 0; i < this.props.library_albums.length; i++){
var uri = this.props.library_albums[i]
var source = helpers.uriSource(uri)
var album = {
uri: uri,
source: source
}
if (this.props.albums.hasOwnProperty(uri)){
switch (this.props.filter){
album = this.props.albums[uri]
}
case 'spotify':
if (this.props.albums[uri].source == 'spotify'){
albums.push(this.props.albums[uri])
}
break
switch (this.props.filter){
case 'local':
if (this.props.albums[uri].source == 'local'){
albums.push(this.props.albums[uri])
}
break
case 'spotify':
if (source == 'spotify'){
albums.push(album)
}
break
default:
albums.push(this.props.albums[uri])
break
}
case 'local':
if (source == 'local'){
albums.push(album)
}
break
default:
albums.push(album)
break
}
}
@ -256,8 +265,10 @@ class LibraryAlbums extends React.Component{
<section className="content-wrapper">
{ this.renderView(albums) }
<LazyLoadListener loading={this.props.library_albums_spotify_more} loadMore={() => this.loadMoreSpotify()}/>
<LazyLoadListener loading={this.moreURIsToLoad().length > 0} loadMore={() => this.loadMoreMopidy()}/>
<LazyLoadListener
loading={this.props.library_albums_more && (this.props.filter == 'all' || this.props.filter == 'spotify')}
loadMore={() => this.loadMoreSpotify()}
/>
</section>
</div>
@ -279,8 +290,8 @@ const mapStateToProps = (state, ownProps) => {
load_queue: state.ui.load_queue,
albums: state.core.albums,
library_albums: state.core.library_albums,
library_albums_spotify_started: state.core.library_albums_spotify_started,
library_albums_spotify_more: state.core.library_albums_spotify_more,
library_albums_started: state.core.library_albums_started,
library_albums_more: state.core.library_albums_more,
view: state.ui.library_albums_view,
filter: (state.ui.library_albums_filter ? state.ui.library_albums_filter : 'all'),
sort: (state.ui.library_albums_sort ? state.ui.library_albums_sort : 'name'),

View File

@ -11,7 +11,7 @@
padding-bottom: 100%;
position: relative;
background-repeat: no-repeat;
background-color: $grey;
background-color: lighten($dark_grey, 2%);
background-position: 50% 50%;
background-size: cover;
border-radius: 3px;

View File

@ -266,6 +266,7 @@ button.placeholder {
.one-liner { @include one_line_text; }
.centred-text { text-align: center; }
.grey-text { color: $mid_grey !important; }
.dark-grey-text { color: lighten($dark_grey, 8%) !important; }
.red-text { color: $red !important; }
.green-text { color: $green !important; }
.orange-text { color: $orange !important; }