refactor
This commit is contained in:
parent
cdb4540d82
commit
1745495d2a
@ -93,11 +93,10 @@
|
||||
},
|
||||
toggleFavourite() {
|
||||
if (this.album) {
|
||||
const value = !this.album.favourite
|
||||
this.album.favourite = value
|
||||
return value
|
||||
? this.$api.addFavourite('album', this.album.id)
|
||||
: this.$api.removeFavourite('album', this.album.id)
|
||||
this.album.favourite = !this.album.favourite
|
||||
return this.album.favourite
|
||||
? this.$api.addFavourite(this.album.id, 'album')
|
||||
: this.$api.removeFavourite(this.album.id, 'album')
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -32,10 +32,9 @@
|
||||
methods: {
|
||||
toggleFavourite() {
|
||||
this.favourite = !this.favourite
|
||||
if (this.favourite) {
|
||||
return this.$api.removeFavourite('track', this.track.id)
|
||||
}
|
||||
return this.$api.addFavourite('track', this.track.id)
|
||||
return this.favourite
|
||||
? this.$api.addFavourite(this.track.id, 'track')
|
||||
: this.$api.removeFavourite(this.track.id, 'track')
|
||||
},
|
||||
download() {
|
||||
window.location.href = this.$api.getDownloadUrl(this.track.id)
|
||||
|
@ -249,7 +249,7 @@ export class API {
|
||||
}
|
||||
}
|
||||
|
||||
async addFavourite(type: 'track' | 'album' | 'artist', id: string) {
|
||||
async addFavourite(id: string, type: 'track' | 'album' | 'artist') {
|
||||
const params = {
|
||||
id: type === 'track' ? id : undefined,
|
||||
albumId: type === 'album' ? id : undefined,
|
||||
@ -258,7 +258,7 @@ export class API {
|
||||
await this.get('rest/star', params)
|
||||
}
|
||||
|
||||
async removeFavourite(type: 'track' | 'album' | 'artist', id: string) {
|
||||
async removeFavourite(id: string, type: 'track' | 'album' | 'artist') {
|
||||
const params = {
|
||||
id: type === 'track' ? id : undefined,
|
||||
albumId: type === 'album' ? id : undefined,
|
||||
|
Loading…
x
Reference in New Issue
Block a user