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) { followingArtist(id) {
console.log(`check for ${id}`)
return this.cfg.home.followedArtists.includes(id) return this.cfg.home.followedArtists.includes(id)
}, },
playMediaItem(item) { playMediaItem(item) {

View file

@ -1,13 +1,13 @@
<script type="text/x-template" id="artist-chip"> <script type="text/x-template" id="artist-chip">
<div class="artist-chip" @click.self="route"> <div class="artist-chip" @click.self="route">
<div class="artist-chip__image"> <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>
<div class="artist-chip__name"> <div class="artist-chip__name">
<span>{{ item.attributes.name }}</span> <span>{{ item.attributes.name }}</span>
</div> </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(artist.id, true)" title="Follow" v-if="!$root.followingArtist(artist.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, false)" title="Following" v-else class="artist-chip__follow codicon codicon-check"></button>
</div> </div>
</script> </script>
@ -21,18 +21,24 @@
}, },
data: function() { data: function() {
return { return {
artist: null artist: {
id: null
}
} }
}, },
template: '#artist-chip', template: '#artist-chip',
async mounted() { 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]; this.artist = response.data.data[0];
}); });
}, },
methods: { methods: {
route() { route() {
app.appRoute(`artist/${this.item.id}`); app.appRoute(`artist/${this.artist.id}`);
} }
} }
}); });

View file

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

View file

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