Images as array, detecting duplicates
This commit is contained in:
@ -460,9 +460,7 @@ export let formatArtist = function(data){
|
||||
}
|
||||
|
||||
if (data.images){
|
||||
artist.images = [
|
||||
formatImages(artist.images)
|
||||
];
|
||||
artist.images = [formatImages(artist.images)];
|
||||
}
|
||||
|
||||
if (data.followers && data.followers.total !== undefined){
|
||||
|
||||
@ -634,7 +634,24 @@ const CoreMiddleware = (function(){
|
||||
// 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];
|
||||
var existing_images = artists_index[artist.uri].images;
|
||||
var are_new_images = true;
|
||||
|
||||
// loop all extisting images to make sure we're not adding one that
|
||||
// we already have
|
||||
for (var existing_image of existing_images){
|
||||
|
||||
// We only need to check one size, the formatter should insist on consistency
|
||||
// Note that we depend on having a one-item array of images provided per action
|
||||
if (existing_image.huge == artist.images[0].huge){
|
||||
are_new_images = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Only if they're new images should we merge them in
|
||||
if (are_new_images){
|
||||
artist.images = Object.assign([], [...existing_images, ...artist.images]);
|
||||
}
|
||||
}
|
||||
|
||||
artist = Object.assign({}, artists_index[artist.uri], artist);
|
||||
|
||||
@ -307,10 +307,21 @@ class Discover extends React.Component{
|
||||
<div className="seeds">
|
||||
{
|
||||
seeds_objects.map((seed,index) => {
|
||||
var type = helpers.uriType(seed.uri)
|
||||
var type = helpers.uriType(seed.uri);
|
||||
var images = null;
|
||||
if (seed.images){
|
||||
if (type == 'artist'){
|
||||
if (seed.images.length > 0){
|
||||
images = seed.images[0];
|
||||
}
|
||||
} else {
|
||||
images = seed.images;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={"seed"+(seed.images ? " has-thumbnail" : "")} key={seed.uri}>
|
||||
{seed.images ? <URILink className="thumbnail-wrapper" type={type} uri={seed.uri}><Thumbnail images={seed.images} circle={seed.type == "artist"} size="small" /></URILink> : null}
|
||||
{images ? <URILink className="thumbnail-wrapper" type={type} uri={seed.uri}><Thumbnail images={images} circle={seed.type == "artist"} size="small" /></URILink> : null}
|
||||
<div className="label">
|
||||
{helpers.titleCase(type)}
|
||||
<Icon name="close" className="remove" onClick={() => this.removeSeed(index)} />
|
||||
|
||||
Reference in New Issue
Block a user