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