Artst images now an array of objects for better gallery support (needs testing)
This commit is contained in:
@ -98,9 +98,13 @@ export default class GridItem extends React.Component{
|
||||
}
|
||||
var images = null
|
||||
if (this.props.item.images){
|
||||
images = this.props.item.images
|
||||
if (Array.isArray(this.props.item.images)){
|
||||
images = this.props.item.images[0];
|
||||
} else {
|
||||
images = this.props.item.images;
|
||||
}
|
||||
} else if (this.props.item.icons){
|
||||
images = this.props.item.icons
|
||||
images = this.props.item.icons;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -16,17 +16,23 @@ export default class RelatedArtists extends React.Component{
|
||||
<div className="list related-artist-list">
|
||||
{
|
||||
this.props.artists.map((artist, index) => {
|
||||
|
||||
var images = artist.images;
|
||||
if (Array.isArray(images)){
|
||||
images = images[0];
|
||||
}
|
||||
|
||||
if (artist.uri){
|
||||
return (
|
||||
<URILink type="artist" uri={artist.uri} key={artist.uri} className="artist">
|
||||
<Thumbnail circle={true} size="small" images={artist.images} />
|
||||
<Thumbnail circle={true} size="small" images={images} />
|
||||
<span className="name">{ artist.name }</span>
|
||||
</URILink>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<span key={artist.uri} className="artist">
|
||||
<Thumbnail circle={true} size="small" images={artist.images} />
|
||||
<Thumbnail circle={true} size="small" images={images} />
|
||||
<span className="name">{ artist.name }</span>
|
||||
</span>
|
||||
)
|
||||
|
||||
@ -459,8 +459,10 @@ export let formatArtist = function(data){
|
||||
}
|
||||
}
|
||||
|
||||
if (artist.images && !artist.images.formatted){
|
||||
artist.images = formatImages(artist.images);
|
||||
if (data.images){
|
||||
artist.images = [
|
||||
formatImages(artist.images)
|
||||
];
|
||||
}
|
||||
|
||||
if (data.followers && data.followers.total !== undefined){
|
||||
|
||||
@ -631,12 +631,11 @@ const CoreMiddleware = (function(){
|
||||
// Already have an artist in the index
|
||||
if (artists_index[artist.uri]){
|
||||
|
||||
// Don't replace existing images, instead add them as supplementary
|
||||
// this is to prevent LastFM overwriting Spotify images
|
||||
if (artists_index[artist.uri].images){
|
||||
artist.images_additional = artist.images;
|
||||
delete artist.images;
|
||||
}
|
||||
// And we've already got some images, make sure we merge the arrays,
|
||||
// rather than overwriting
|
||||
if (artists_index[artist.uri].images && artist.images){
|
||||
artist.images = [...artists_index[artist.uri].images, ...artist.images];
|
||||
}
|
||||
|
||||
artist = Object.assign({}, artists_index[artist.uri], artist);
|
||||
}
|
||||
@ -652,7 +651,6 @@ const CoreMiddleware = (function(){
|
||||
artists_loaded.push(artist);
|
||||
};
|
||||
|
||||
|
||||
action.artists = artists_loaded;
|
||||
|
||||
if (tracks_loaded.length > 0){
|
||||
|
||||
@ -2009,9 +2009,9 @@ const MopidyMiddleware = (function(){
|
||||
var existing_artist = store.getState().core.artists[artist.uri];
|
||||
if (existing_artist && !existing_artist.images){
|
||||
if (artist.musicbrainz_id){
|
||||
store.dispatch(lastfmActions.getArtist(artist.uri, false, artist.musicbrainz_id))
|
||||
store.dispatch(lastfmActions.getArtist(artist.uri, false, artist.musicbrainz_id));
|
||||
} else {
|
||||
store.dispatch(lastfmActions.getArtist(artist.uri, artist.name))
|
||||
store.dispatch(lastfmActions.getArtist(artist.uri, artist.name));
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -41,7 +41,7 @@ class Artist extends React.Component{
|
||||
if (nextProps.params.uri != this.props.params.uri){
|
||||
this.props.coreActions.loadArtist(nextProps.params.uri);
|
||||
|
||||
}else if (!this.props.mopidy_connected && nextProps.mopidy_connected){
|
||||
} else if (!this.props.mopidy_connected && nextProps.mopidy_connected){
|
||||
if (helpers.uriSource(this.props.params.uri ) != 'spotify'){
|
||||
this.props.coreActions.loadArtist(nextProps.params.uri);
|
||||
}
|
||||
@ -146,12 +146,23 @@ class Artist extends React.Component{
|
||||
)
|
||||
|
||||
case 'about':
|
||||
|
||||
var thumbnails = [];
|
||||
if (artist.images && artist.images.length > 0){
|
||||
for (var i = 0; i < artist.images.length; i++){
|
||||
thumbnails.push(
|
||||
<div className="tile thumbnail-wrapper" key={i}>
|
||||
<Thumbnail size="huge" canZoom images={artist.images[i]} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="body about">
|
||||
|
||||
<div className="col col--w40 tiles artist-stats">
|
||||
{artist.images ? <div className="tile thumbnail-wrapper"><Thumbnail size="huge" canZoom images={artist.images} /></div> : null}
|
||||
{artist.images_additional ? <div className="tile thumbnail-wrapper"><Thumbnail size="huge" canZoom images={artist.images_additional} /></div> : null}
|
||||
{thumbnails}
|
||||
{artist.followers ? <div className="tile"><span className="content"><Icon type="fontawesome" name="users" />{artist.followers.toLocaleString()} followers</span></div> : null}
|
||||
{artist.popularity ? <div className="tile"><span className="content"><Icon type="fontawesome" name="fire" />{artist.popularity }% popularity</span></div> : null}
|
||||
{artist.listeners ? <div className="tile"><span className="content"><Icon type="fontawesome" name="headphones" />{ artist.listeners.toLocaleString() } listeners</span></div> : null }
|
||||
@ -278,8 +289,8 @@ class Artist extends React.Component{
|
||||
}
|
||||
}
|
||||
|
||||
if (this.props.artist && this.props.artist.images){
|
||||
var image = this.props.artist.images.huge;
|
||||
if (this.props.artist && this.props.artist.images && this.props.artist.images.length > 0){
|
||||
var image = this.props.artist.images[0].huge;
|
||||
} else {
|
||||
var image = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user