Album sorted
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -28,23 +28,31 @@ export default function reducer(ui = {}, action){
|
||||
* Playlists/albums/etc
|
||||
**/
|
||||
|
||||
case 'SPOTIFY_ALBUM_LOADED':
|
||||
case 'MOPIDY_ALBUM_LOADED':
|
||||
return Object.assign({}, ui, { album: action.data });
|
||||
|
||||
case 'LASTFM_ALBUM_LOADED':
|
||||
//if( !action.data.image ) return ui
|
||||
var album = Object.assign(ui.album, { images: action.data.image })
|
||||
if( !action.data.image ) return ui
|
||||
|
||||
var album = Object.assign({}, ui.album, { images: action.data.image })
|
||||
return Object.assign({}, ui, { album: album });
|
||||
|
||||
case 'SPOTIFY_ALBUM_LOADED':
|
||||
if( !action.data ) return Object.assign({}, ui, { album: false })
|
||||
|
||||
console.log(action.data)
|
||||
var album = Object.assign({}, { images: [] }, action.data, {
|
||||
tracks: action.data.tracks.items,
|
||||
tracks_total: action.data.tracks.total,
|
||||
tracks_more: action.data.tracks.next
|
||||
})
|
||||
return Object.assign({}, ui, { album: album })
|
||||
|
||||
case 'SPOTIFY_ALBUM_LOADED_MORE':
|
||||
var album = ui.album
|
||||
Object.assign(album, { tracks: {
|
||||
href: action.data.href,
|
||||
next: action.data.next,
|
||||
previous: action.data.previous,
|
||||
items: [ ...ui.album.tracks.items, ...action.data.items ]
|
||||
}})
|
||||
var album = Object.assign({}, ui.album, {
|
||||
tracks: [ ...ui.album.tracks, ...action.data.items ],
|
||||
tracks_more: action.data.next
|
||||
})
|
||||
return Object.assign({}, ui, { album: album });
|
||||
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ class Album extends React.Component{
|
||||
}
|
||||
|
||||
componentWillReceiveProps( nextProps ){
|
||||
console.log('componentWillReceiveProps')
|
||||
|
||||
// if our URI has changed, fetch new album
|
||||
if( nextProps.params.uri != this.props.params.uri ){
|
||||
@ -55,13 +54,8 @@ class Album extends React.Component{
|
||||
}
|
||||
|
||||
loadMore(){
|
||||
if( !this.props.album.tracks.next ) return
|
||||
this.props.spotifyActions.getURL( this.props.album.tracks.next, 'SPOTIFY_ALBUM_LOADED_MORE' );
|
||||
}
|
||||
|
||||
renderThumbnail(){
|
||||
if( !this.props.album.images ) return <Thumbnail size="large" images={[]} />
|
||||
return <Thumbnail size="large" images={ this.props.album.images } />
|
||||
if( !this.props.album.tracks_more ) return
|
||||
this.props.spotifyActions.getURL( this.props.album.tracks_more, 'SPOTIFY_ALBUM_LOADED_MORE' );
|
||||
}
|
||||
|
||||
render(){
|
||||
@ -70,10 +64,10 @@ class Album extends React.Component{
|
||||
return (
|
||||
<div className="view album-view">
|
||||
<div className="intro">
|
||||
{ this.renderThumbnail() }
|
||||
<Thumbnail size="large" images={ this.props.album.images } />
|
||||
<ArtistGrid artists={ this.props.album.artists } />
|
||||
<ul className="details">
|
||||
<li>{ this.props.album.tracks.total } tracks, <Dater type="total-time" data={this.props.album.tracks.items} /></li>
|
||||
<li>{ this.props.album.tracks_total } tracks, <Dater type="total-time" data={this.props.album.tracks} /></li>
|
||||
{ this.props.album.release_date ? <li>Released <Dater type="date" data={ this.props.album.release_date } /></li> : null }
|
||||
<li><FontAwesome name={helpers.sourceIcon( this.props.params.uri )} /> {helpers.uriSource( this.props.params.uri )} playlist</li>
|
||||
</ul>
|
||||
@ -86,7 +80,7 @@ class Album extends React.Component{
|
||||
</div>
|
||||
|
||||
<section className="list-wrapper">
|
||||
<TrackList tracks={ this.props.album.tracks.items } />
|
||||
{ this.props.album.tracks ? <TrackList tracks={ this.props.album.tracks } /> : null }
|
||||
<LazyLoadListener loadMore={ () => this.loadMore() }/>
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user