import React from 'react';
import {
uriType,
scrollTo,
sourceIcon,
uriSource,
} from '../util/helpers';
import Link from './Link';
import Icon from './Icon';
import Thumbnail from './Thumbnail';
import LinksSentence from './LinksSentence';
export default class GridItem extends React.Component {
componentDidMount() {
const {
lastfmActions,
mopidyActions,
spotifyActions,
spotifyAvailable,
item,
} = this.props;
if (!item || item.images) return;
switch (uriType(item.uri)) {
case 'artist':
if (spotifyActions && spotifyAvailable) {
spotifyActions.getArtistImages(item);
}
break;
case 'album':
// If Mopidy doesn't find any images, then it will pass on the call to LastFM
mopidyActions.getImages('albums', [item.uri]);
break;
default:
break;
}
}
shouldComponentUpdate = (nextProps) => {
const { item } = this.props;
return nextProps.item !== item;
}
onContextMenu = (e) => {
const { onContextMenu } = this.props;
if (onContextMenu) {
onContextMenu(e);
}
}
renderSecondary = (item) => {
const output = '';
const link_to = null;
switch (uriType(item.uri)) {
case 'playlist':
if (item.tracks_total) {
return (
{item.tracks_total}
{' '}
tracks
);
}
break;
case 'artist':
return (
{item.followers !== undefined ? `${item.followers.toLocaleString()} followers ` : null}
{item.albums_uris !== undefined ? `${item.albums_uris.length} albums` : null}
);
break;
case 'album':
return (
{item.artists !== undefined ?