From ae9669c3f94943abf0cb5b4b6cea67f0c01f0a81 Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Thu, 24 Feb 2022 05:24:04 -0800 Subject: [PATCH] fix for library artists --- src/renderer/index.js | 1 + src/renderer/views/components/artist-chip.ejs | 18 ++++++++++----- src/renderer/views/pages/cider-playlist.ejs | 21 +++++++++++++----- src/renderer/views/pages/playlist-inline.ejs | 22 ++++++++++++++----- 4 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/renderer/index.js b/src/renderer/index.js index aece077d..a3c15d61 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -1585,6 +1585,7 @@ const app = new Vue({ } }, followingArtist(id) { + console.log(`check for ${id}`) return this.cfg.home.followedArtists.includes(id) }, playMediaItem(item) { diff --git a/src/renderer/views/components/artist-chip.ejs b/src/renderer/views/components/artist-chip.ejs index c6b60ee0..6d2734e4 100644 --- a/src/renderer/views/components/artist-chip.ejs +++ b/src/renderer/views/components/artist-chip.ejs @@ -1,13 +1,13 @@ @@ -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}`); } } }); diff --git a/src/renderer/views/pages/cider-playlist.ejs b/src/renderer/views/pages/cider-playlist.ejs index 27229fdf..4256299c 100644 --- a/src/renderer/views/pages/cider-playlist.ejs +++ b/src/renderer/views/pages/cider-playlist.ejs @@ -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) }, diff --git a/src/renderer/views/pages/playlist-inline.ejs b/src/renderer/views/pages/playlist-inline.ejs index 520aaf4a..c360f917 100644 --- a/src/renderer/views/pages/playlist-inline.ejs +++ b/src/renderer/views/pages/playlist-inline.ejs @@ -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) {