Use proper method for fetching artist cover

This commit is contained in:
Ciaran Ainsworth 2022-02-06 18:50:26 +01:00 committed by Georg Krause
parent c1694a808c
commit 7b74e55e7f
3 changed files with 18 additions and 7 deletions

View File

@ -34,6 +34,12 @@
:src="currentTrack.cover"
alt="Cover"
>
<img
v-else-if="artistCover"
height="120"
:src="artistCover"
alt="Cover"
>
<img
v-else
height="120"
@ -258,9 +264,6 @@ function getURLParams () {
export default {
name: 'App',
components: { Logo },
props: {
artistCover: { type: Object, required: false, default: () => { return null } }
},
data () {
return {
time,
@ -275,6 +278,7 @@ export default {
isLoading: true,
theme: 'dark',
currentIndex: -1,
artistCover: null,
themes: {
dark: {
textColor: 'white'
@ -385,6 +389,7 @@ export default {
}
if (type === 'artist') {
this.fetchTracks({ artist: id, playable: true, include_channels: 'true', ordering: '-album__release_date,disc_number,position' })
this.fetchArtistCover(id)
}
if (type === 'playlist') {
this.fetchTracks({}, `/api/v1/playlists/${id}/tracks/`)
@ -463,6 +468,15 @@ export default {
}
})
},
fetchArtistCover (id) {
const self = this
self.isLoading = true
const url = `${this.baseUrl}/api/v1/artists/${id}/`
axios.get(url).then(response => {
self.isLoading = false
self.artistCover = response.data.cover.urls.medium_square_crop
})
},
bindEvents () {
const self = this
this.$refs.player.player.on('ended', () => {

View File

@ -98,7 +98,6 @@
scrolling="no"
frameborder="no"
:src="iframeSrc"
:artist-cover="cover"
/>
</div>
</div>
@ -112,8 +111,7 @@ import _ from '@/lodash'
export default {
props: {
type: { type: String, required: true },
id: { type: Number, required: true },
cover: { type: Object, required: false, default: () => { return null } }
id: { type: Number, required: true }
},
data () {
const d = {

View File

@ -320,7 +320,6 @@
<div class="description">
<embed-wizard
:id="object.artist.id"
:cover="object.artist.cover"
type="artist"
/>
</div>