fix for library artists

This commit is contained in:
booploops 2022-02-24 05:24:04 -08:00
parent 9b05cde0d2
commit ae9669c3f9
4 changed files with 45 additions and 17 deletions

View file

@ -1585,6 +1585,7 @@ const app = new Vue({
}
},
followingArtist(id) {
console.log(`check for ${id}`)
return this.cfg.home.followedArtists.includes(id)
},
playMediaItem(item) {

View file

@ -1,13 +1,13 @@
<script type="text/x-template" id="artist-chip">
<div class="artist-chip" @click.self="route">
<div class="artist-chip__image">
<mediaitem-artwork v-if="artist != null" :url="artist.attributes.artwork.url" :size="32"></mediaitem-artwork>
<mediaitem-artwork v-if="artist.id != null" :url="artist.attributes.artwork.url" :size="32"></mediaitem-artwork>
</div>
<div class="artist-chip__name">
<span>{{ item.attributes.name }}</span>
</div>
<button @click="$root.followArtistById(item.id, true)" title="Follow" v-if="!$root.followingArtist(item.id)" class="artist-chip__follow codicon codicon-add"></button>
<button @click="$root.followArtistById(item.id, false)" title="Following" v-else class="artist-chip__follow codicon codicon-check"></button>
<button @click="$root.followArtistById(artist.id, true)" title="Follow" v-if="!$root.followingArtist(artist.id)" class="artist-chip__follow codicon codicon-add"></button>
<button @click="$root.followArtistById(artist.id, false)" title="Following" v-else class="artist-chip__follow codicon codicon-check"></button>
</div>
</script>
@ -21,18 +21,24 @@
},
data: function() {
return {
artist: null
artist: {
id: null
}
}
},
template: '#artist-chip',
async mounted() {
app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/artists/${this.item.id}`).then(response => {
let artistId = this.item.id
if(typeof this.item.relationships.catalog == "object") {
artistId = this.item.relationships.catalog.data[0].id
}
app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/artists/${artistId}`).then(response => {
this.artist = response.data.data[0];
});
},
methods: {
route() {
app.appRoute(`artist/${this.item.id}`);
app.appRoute(`artist/${this.artist.id}`);
}
}
});

View file

@ -221,7 +221,7 @@
itemBadges: [],
badgesRequested: false,
headerVisible: true,
useArtistChip: false
useArtistChip: false,
}
},
mounted: function () {
@ -414,6 +414,15 @@
},
menu(event) {
let self = this
let artistId = null
if(typeof this.data.relationships.artists != "undefined") {
artistId = this.data.relationships.artists.data[0].id
if(this.data.relationships.artists.data[0].type == "library-artists") {
artistId = this.data.relationships.artists.data[0].relationships.catalog.data[0].id
}
}
let menuItems = {
items: {
"share": {
@ -449,7 +458,7 @@
icon: "./assets/feather/plus-circle.svg",
hidden: false,
action: () => {
app.followArtistById(this.data.relationships.artists.data[0].id, true)
app.followArtistById(artistId, true)
}
},
"unfollow": {
@ -457,13 +466,14 @@
icon: "./assets/feather/x-circle.svg",
hidden: true,
action: () => {
app.followArtistById(this.data.relationships.artists.data[0].id, false)
app.followArtistById(artistId, false)
}
},
}
}
if(typeof this.data.relationships.artists != "undefined") {
if(app.followingArtist(this.data.relationships.artists.data[0].id)){
if(artistId != null) {
if(app.followingArtist(artistId)){
menuItems.items.follow.hidden = true
menuItems.items.unfollow.hidden = false
} else {
@ -475,6 +485,7 @@
menuItems.items.unfollow.hidden = true
}
app.showMenuPanel(menuItems, event)
},

View file

@ -245,7 +245,7 @@
itemBadges: [],
badgesRequested: false,
headerVisible: true,
useArtistChip: false
useArtistChip: false,
}
},
mounted: function () {
@ -438,6 +438,15 @@
},
menu(event) {
let self = this
let artistId = null
if(typeof this.data.relationships.artists != "undefined") {
artistId = this.data.relationships.artists.data[0].id
if(this.data.relationships.artists.data[0].type == "library-artists") {
artistId = this.data.relationships.artists.data[0].relationships.catalog.data[0].id
}
}
let menuItems = {
items: {
"share": {
@ -473,7 +482,7 @@
icon: "./assets/feather/plus-circle.svg",
hidden: false,
action: () => {
app.followArtistById(this.data.relationships.artists.data[0].id, true)
app.followArtistById(artistId, true)
}
},
"unfollow": {
@ -481,13 +490,14 @@
icon: "./assets/feather/x-circle.svg",
hidden: true,
action: () => {
app.followArtistById(this.data.relationships.artists.data[0].id, false)
app.followArtistById(artistId, false)
}
},
}
}
if(typeof this.data.relationships.artists != "undefined") {
if(app.followingArtist(this.data.relationships.artists.data[0].id)){
if(artistId != null) {
if(app.followingArtist(artistId)){
menuItems.items.follow.hidden = true
menuItems.items.unfollow.hidden = false
} else {
@ -499,8 +509,8 @@
menuItems.items.unfollow.hidden = true
}
app.showMenuPanel(menuItems, event)
app.showMenuPanel(menuItems, event)
},
getItemParent: function (data) {