From 1489daaad148746844e25daafe04011000597c18 Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Fri, 25 Nov 2016 09:12:56 +1300 Subject: [PATCH] Fixing mibd from url for lastfm artwork --- src/js/helpers.js | 2 +- src/js/services/ui/reducer.js | 6 +++++- src/js/views/Artist.js | 12 +++++++++++- src/scss/global/_core.scss | 9 ++++++++- 4 files changed, 25 insertions(+), 4 deletions(-) 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

-

Biography here

+ { this.props.artist.bio ?

{this.props.artist.bio.content}


+
Published: { this.props.artist.bio.published }
+
Origin: { this.props.artist.bio.links.link.href }
: null }
) diff --git a/src/scss/global/_core.scss b/src/scss/global/_core.scss index ddbdd665..77b1a872 100755 --- a/src/scss/global/_core.scss +++ b/src/scss/global/_core.scss @@ -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; }