Skip to content

Commit

Permalink
Fix artist/album pages
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeop committed Feb 22, 2020
1 parent 6e2ce87 commit db36511
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 50 deletions.
2 changes: 1 addition & 1 deletion packages/app/app/components/AlbumView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class AlbumView extends React.Component {
}

getAlbumImage (album) {
return _.get(album, 'coverImage.uri');
return _.get(album, 'coverImage');
}

renderAlbumArtistName (album) {
Expand Down
61 changes: 32 additions & 29 deletions packages/app/app/components/ArtistView/ArtistTags/index.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router-dom';
import { compose, withHandlers } from 'recompose';

import styles from './styles.scss';

class ArtistTags extends React.Component {
constructor(props) {
super(props);
}
const ArtistTags = ({
tags,
onTagClick
}) => (
<div className={styles.tags_container}>
{
tags && tags.length > 0 &&
tags.map((tag, i) => {
return (
<a
href='#'
onClick={() => onTagClick(tag)}
key={i}
className={styles.tag}
>#{tag}</a>
);
})
}
</div>
);

onTagClick(tag) {
this.props.history.push('/tag/' + tag);
}
ArtistTags.propTypes = {
tags: PropTypes.arrayOf(PropTypes.string)
};

render() {
return (
<div className={styles.tags_container}>
{
this.props.tags && this.props.tags.length > 0 &&
this.props.tags.map((el, i) => {
return (
<a
href='#'
onClick={() => this.onTagClick.bind(this)(el.name)}
key={i}
className={styles.tag}
>#{el.name}</a>
);
})
}
</div>
);
}
}

export default ArtistTags;
export default compose(
withRouter,
withHandlers({
onTagClick: ({ history }) => tag => history.push(`/tag/${tag}`)
})
)(ArtistTags);
4 changes: 2 additions & 2 deletions packages/app/app/components/ArtistView/PopularTracks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PopularTracks extends React.Component {
this.props.addToQueue(this.props.streamProviders, {
artist: artist.name,
name: track.name,
thumbnail: track.thumbnail || track.image[0]['#text'] || artPlaceholder
thumbnail: track.thumb || artPlaceholder
});
});
}}
Expand Down Expand Up @@ -71,7 +71,7 @@ class PopularTracks extends React.Component {
</thead>
<tbody>
{
_.get(tracks, 'track', [])
tracks
.slice(0, this.state.expanded ? 15 : 5)
.map((track, index) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
margin: 0.15rem 0;
padding: 0.5rem;

transition: $short-duration ease-in-out;
transition: $short-duration;

border-radius: 2px;
background: $background2;
Expand Down
6 changes: 3 additions & 3 deletions packages/app/app/components/ArtistView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ArtistView extends React.Component {
className={styles.artist_avatar}
style={{
background: `url('${
_.get(artist, 'images[1].resource_url', artPlaceholder)
_.get(artist, 'images[1]', artPlaceholder)
}')`,
backgroundRepeat: 'noRepeat',
backgroundPosition: 'center',
Expand Down Expand Up @@ -92,7 +92,7 @@ class ArtistView extends React.Component {
return (
!this.isLoading() &&
<SimilarArtists
artists={_.get(artist, 'lastfm.artist.similar.artist', [])}
artists={_.get(artist, 'similar', [])}
artistInfoSearchByName={artistInfoSearchByName}
history={history}
/>
Expand All @@ -106,7 +106,7 @@ class ArtistView extends React.Component {
<div
style={{
background: `url('${
_.get(artist, 'images[0].resource_url', artPlaceholder)
_.get(artist, 'coverImage', artPlaceholder)
}')`,
backgroundRepeat: 'noRepeat',
backgroundPosition: 'center',
Expand Down
12 changes: 10 additions & 2 deletions packages/app/app/components/TrackRow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ class TrackRow extends React.Component {
getTrackThumbnail() {
const thumb = _.get(
this.props.track,
'thumbnail',
_.get(this.props.track, 'image[0][#text]', artPlaceholder)
'thumb',
_.get(
this.props.track,
'thumbnail',
_.get(
this.props.track,
'image[0][#text]',
artPlaceholder
)
)
);

return thumb === '' ? artPlaceholder : thumb;
Expand Down
18 changes: 10 additions & 8 deletions packages/core/src/plugins/meta/discogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class DiscogsMetaProvider extends MetaProvider {

return {
id: `${release.id}`,
coverImage: release.cover_image.resource_url,
thumb: release.cover_image.resource_url,
coverImage: release.cover_image,
thumb: release.cover_image,
title: match.groups.album,
artist: match.groups.artist,
resourceUrl: release.resource_url,
Expand All @@ -54,14 +54,15 @@ class DiscogsMetaProvider extends MetaProvider {
}

discogsReleaseInfoToGeneric(release: DiscogsReleaseInfo, releaseType: AlbumType): AlbumDetails {
const primaryImage = _.find(release.images, { type: 'primary' });
const artist = _.head(release.artists).name;
const coverImage = _.get(_.find(release.images, { type: 'primary' }), 'resource_url');

return {
...release,
id: `${release.id}`,
artist: _.head(release.artists).name,
thumb: release.cover_image.resource_url,
coverImage: release.cover_image.resource_url,
thumb: coverImage,
coverImage: coverImage,
images: _.map(release.images, 'resource_url'),
genres: [...release.genres, ...release.styles],
type: releaseType,
Expand All @@ -85,7 +86,7 @@ class DiscogsMetaProvider extends MetaProvider {
.then(response => response.json())
.then((json: DiscogsArtistSearchResponse) => json.results.map(artist => ({
id: `${artist.id}`,
coverImage: artist.cover_image.resource_url,
coverImage: artist.cover_image,
thumb: artist.thumb,
name: artist.title,
resourceUrl: artist.resource_url,
Expand Down Expand Up @@ -136,11 +137,12 @@ class DiscogsMetaProvider extends MetaProvider {
title: track.name,
thumb: (_.get(discogsInfo.images, 1) as DiscogsImage).resource_url,
playcount: track.playcount,
listeners: track.listeners
listeners: track.listeners,
artist: track.artist
})),
similar: _.map(lastFmInfo.similar.artist, artist => ({
name: artist.name,
thumbnail: _.find(artist.image, { size: 'large' })
thumbnail: _.get(_.find(artist.image, { size: 'large' }), '#text')
})),
source: SearchResultsSource.Discogs
});
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/plugins/meta/musicbrainz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class MusicbrainzMetaProvider extends MetaProvider {
})),
similar: _.map(lastFmInfo.similar.artist, artist => ({
name: artist.name,
thumbnail: _.find(artist.image, { size: 'large' })
thumbnail: _.get(_.find(artist.image, { size: 'large' }), '#text')
})),
source: SearchResultsSource.Musicbrainz
});
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/plugins/plugins.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type SearchResultsTrack = {
}

export type ArtistTopTrack = {
artist: string;
artist: { name: string };
title: string;
thumb?: string;
playcount?: number;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/rest/Discogs.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type DiscogsPagination = {

export type DiscogsReleaseSearchResult = {
id: number;
cover_image: DiscogsImage;
cover_image: string;
genre: string[];
style: string[];
resource_url: string;
Expand All @@ -37,7 +37,7 @@ export type DiscogsReleaseSearchResult = {

export type DiscogsArtistSearchResult = {
id: number;
cover_image: DiscogsImage;
cover_image: string;
resource_url: string;
thumb: string;
title: string;
Expand Down
1 change: 1 addition & 0 deletions packages/ui/lib/components/SearchBox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const SearchBox = ({
>
<Icon name='search' disabled={disabled}/>
<input
autoFocus
placeholder={placeholder}
onChange={onChange}
disabled={disabled}
Expand Down

0 comments on commit db36511

Please sign in to comment.