Play all artist tracks, fixes #395

This commit is contained in:
James Barnsley
2020-11-23 20:45:42 +13:00
parent bbf81003be
commit a3a99a8e7c
6 changed files with 181 additions and 133 deletions

View File

@ -123,17 +123,26 @@ class Artist extends React.Component {
trackEvent({ category: 'Artist', action: `Sort${type}`, label: `${value} ${reverse ? 'DESC' : 'ASC'}` });
}
onPlay = () => {
onPlayAll = () => {
const {
artist: {
uri,
tracks,
albums_uris,
},
uiActions: {
createNotification,
},
mopidyActions: {
playURIs,
},
} = this.props;
if ((!albums_uris || !albums_uris.length) && (!tracks || !tracks.length)) {
createNotification({ content: i18n('errors.no_results'), level: 'warning' });
return;
}
playURIs(arrayOf('uri', tracks) || albums_uris, uri);
}
@ -159,6 +168,7 @@ class Artist extends React.Component {
context: 'artist',
items: [artist],
uris: [uri],
tracklist_uri: uri,
});
}
@ -507,7 +517,7 @@ class Artist extends React.Component {
<div className="actions">
<Button
type="primary"
onClick={this.onPlay}
onClick={this.onPlayAll}
tracking={{ category: 'Artist', action: 'Play' }}
>
<I18n path="actions.play" />