Commit 0dea1125 authored by Henrik Hüttemann's avatar Henrik Hüttemann 🤔

Seperate filteredAlbum and album; Fix #8

parent f22f3a86
Pipeline #752 passed with stage
in 1 minute and 17 seconds
......@@ -35,10 +35,10 @@
</div>
</v-tab>
<v-tab v-bind:title="`Albums (${albums.length})`">
<v-tab v-bind:title="`Albums (${filteredAlbums.length})`">
<Album
class="albums"
v-for="album in albums"
v-for="album in filteredAlbums"
v-bind:key="album.releaseId"
v-bind:album="album"
v-bind:search="search"
......@@ -228,7 +228,7 @@ export default {
},
albums: function () {
let albums = []
this.filteredSongs.map(song => {
this.songs.map(song => {
let album = albums.find(a => a.releaseId === song.metadata.musicbrainz_albumid)
if (album === undefined) {
album = {
......@@ -246,6 +246,27 @@ export default {
})
albums.map(album => album.songs.sort((a, b) => a.metadata.track.no - b.metadata.track.no))
return albums
},
filteredAlbums: function () {
let filteredAlbums = []
this.filteredSongs.map(song => {
let album = filteredAlbums.find(a => a.releaseId === song.metadata.musicbrainz_albumid)
if (album === undefined) {
album = {
releaseId: song.metadata.musicbrainz_albumid,
cover: this.getCoverUrl(song.cover),
artist: song.metadata.albumartist,
title: song.metadata.album,
year: song.metadata.year,
tracks: song.metadata.track.of,
songs: []
}
filteredAlbums.push(album)
}
album.songs.push(song)
})
filteredAlbums.map(album => album.songs.sort((a, b) => a.metadata.track.no - b.metadata.track.no))
return filteredAlbums
}
},
methods: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment