diff --git a/src/js/helpers.js b/src/js/helpers.js index 3c9aa7d6..f630ca7c 100755 --- a/src/js/helpers.js +++ b/src/js/helpers.js @@ -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' ){ diff --git a/src/js/services/ui/reducer.js b/src/js/services/ui/reducer.js index d7b97e0b..1e51db41 100755 --- a/src/js/services/ui/reducer.js +++ b/src/js/services/ui/reducer.js @@ -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': diff --git a/src/js/views/Artist.js b/src/js/views/Artist.js index 1287e64e..a5e632fc 100755 --- a/src/js/views/Artist.js +++ b/src/js/views/Artist.js @@ -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{
Biography here
+ { this.props.artist.bio ?{this.props.artist.bio.content}