Fixing mibd from url for lastfm artwork

This commit is contained in:
James Barnsley
2016-11-25 09:12:56 +13:00
parent 33f27b1767
commit 1489daaad1
4 changed files with 25 additions and 4 deletions

View File

@ -111,7 +111,7 @@ export let getFromUri = function( element, uri ){
if( element == 'mbid'){
var index = exploded.indexOf('mbid')
return exploded[index+1]
if( index > -1 ) return exploded[index+1]
}
if( exploded[0] == 'spotify' ){

View File

@ -167,7 +167,11 @@ export default function reducer(ui = {}, action){
case 'LASTFM_ARTIST_LOADED':
if( !action.data.image ) return ui
var artist = Object.assign({}, ui.artist, { images: action.data.image, bio: action.data.bio })
// if we already have images, don't overwrite them
var images = ui.artist.images
if( images.length <= 0 ) images = action.data.image
var artist = Object.assign({}, ui.artist, { images: images, bio: action.data.bio }, )
return Object.assign({}, ui, { artist: artist });
case 'SPOTIFY_ARTIST_LOADED':

View File

@ -44,6 +44,14 @@ class Artist extends React.Component{
}
}
componentWillUpdate( nextProps, nextState ){
if( nextState.sub_view != this.state.sub_view && nextState.sub_view == 'biography' ){
if( this.props.artist && !this.props.artist.bio ){
this.props.lastfmActions.getArtist( this.props.artist.name.replace('&','and') )
}
}
}
loadArtist( props = this.props ){
var source = helpers.uriSource( props.params.uri );
if( source == 'spotify' ){
@ -94,7 +102,9 @@ class Artist extends React.Component{
<div className="body biography">
<h4 className="left-padding">Biography</h4>
<section className="text-wrapper no-top-padding">
<p>Biography here</p>
{ this.props.artist.bio ? <div><p>{this.props.artist.bio.content}</p><br />
<div className="grey-text">Published: { this.props.artist.bio.published }</div>
<div className="grey-text">Origin: <a href={ this.props.artist.bio.links.link.href } target="_blank">{ this.props.artist.bio.links.link.href }</a></div></div> : null }
</section>
</div>
)

View File

@ -45,7 +45,14 @@ main {
}
}
section.grid-wrapper {
p {
font-size: 18px;
line-height: 1.5em;
white-space: pre-wrap;
}
section.grid-wrapper,
section.text-wrapper {
padding: 40px;
}