artist clicking fallback to primary artist if multiple artists

This commit is contained in:
Core 2022-09-11 00:48:56 +01:00
parent 6a4346028e
commit 23a889e11a
No known key found for this signature in database
GPG key ID: 2AB8327FBA02D1C0
2 changed files with 13 additions and 4 deletions

View file

@ -83,7 +83,7 @@ const MusicKitInterop = {
});
},
async fetchPrimaryArtist() {
async fetchPrimaryArtist(returnType = "name") {
const songID = app.mk.nowPlayingItem.attributes.playParams.catalogId || app.mk.nowPlayingItem.attributes.playParams.id;
const res = await MusicKit.getInstance().api.v3.music("/v1/catalog/" + MusicKit.getInstance().storefrontId + `/songs/${songID}`, {
include: {
@ -107,7 +107,11 @@ const MusicKitInterop = {
}
const primaryArtist = artistData[0];
if (returnType === "name") {
return primaryArtist.attributes.name;
} else if (returnType === "id") {
return primaryArtist.id;
}
},
getAttributes: function () {

View file

@ -4535,8 +4535,13 @@ const app = new Vue({
{
icon: "./assets/feather/user.svg",
name: app.getLz("action.goToArtist"),
action: function () {
action: async function () {
if (app.mk.nowPlayingItem.relationships.artists.data[0].id) {
app.appRoute(`artist/${app.mk.nowPlayingItem.relationships.artists.data[0].id}`);
} else {
const id = await MusicKitInterop.fetchPrimaryArtist("id")
app.appRoute(`artist/${id}`);
}
},
},
{