Subdirectories now route to artist/album/playlist if backend type provided

This commit is contained in:
James Barnsley
2021-04-29 21:01:15 +12:00
parent 74aa6e471a
commit c5c818b36f
10 changed files with 52 additions and 23 deletions

View File

@ -104,8 +104,9 @@ const GridItem = ({
// Build link
let to = '';
if (getLink) {
to = getLink(item);
const getLinkResult = getLink ? getLink(item) : undefined;
if (getLinkResult) {
to = getLinkResult;
} else if (item.link) {
to = item.link;
} else {

View File

@ -133,8 +133,9 @@ const ListItem = ({
*/
const onClick = (e) => {
let to = '';
if (getLink) {
to = getLink(item);
const getLinkResult = getLink ? getLink(item) : undefined;
if (getLinkResult) {
to = getLinkResult;
} else if (item.link) {
to = item.link;
} else {

View File

@ -1663,6 +1663,13 @@ const MopidyMiddleware = (function () {
} else if (item.__model__ === 'Ref' && item.type === 'album') {
subdirectories.push(formatAlbum({ ...item, loading: true }));
subdirectoryImagesToLoad.push(item.uri);
} else if (item.__model__ === 'Ref' && item.type === 'artist') {
subdirectories.push(formatArtist({ ...item, loading: true }));
subdirectoryImagesToLoad.push(item.uri);
} else if (item.__model__ === 'Ref' && item.type === 'playlist') {
console.debug('playlist', { item })
subdirectories.push(formatPlaylist({ ...item, loading: true }));
subdirectoryImagesToLoad.push(item.uri);
} else {
subdirectories.push(item);
}

View File

@ -57,6 +57,7 @@ class DiscoverCategories extends React.Component {
className="grid--tiles"
items={categories}
getLink={(item) => `/discover/categories/${encodeUri(item.uri)}`}
sourceIcon={false}
/>
</section>
</div>

View File

@ -31,7 +31,6 @@ class LibraryBrowse extends React.Component {
const {
loading,
directory,
mopidyActions,
} = this.props;
if (!directory) {

View File

@ -37,7 +37,12 @@ const Breadcrumbs = ({ uri }) => {
const Subdirectories = ({ items, view }) => {
if (!items.length) return null;
const link = (item) => `/library/browse/${encodeURIComponent(item.name)}/${encodeUri(item.uri)}`;
// Only define the link for directories; allows URILink to intelligently route based on type
const link = (item) => (
item.type === 'directory'
? `/library/browse/${encodeURIComponent(item.name)}/${encodeUri(item.uri)}`
: null
);
if (view === 'list') {
return (