Commit aabcc3c5 authored by Ciarán Ainsworth's avatar Ciarán Ainsworth Committed by Agate

Resolve 1228 multi-disc albums

parent 0c5df9e6
Pipeline #12322 passed with stages
in 6 minutes and 4 seconds
Fixed duplication of discs for multi-disc albums in album views (#1228)
\ No newline at end of file
......@@ -134,15 +134,17 @@ import TagsList from "@/components/tags/List"
import ArtistLabel from '@/components/audio/ArtistLabel'
import AlbumDropdown from './AlbumDropdown'
function groupByDisc(acc, track) {
var dn = track.disc_number - 1
if (dn < 0) dn = 0
if (acc[dn] == undefined) {
acc.push([track])
} else {
acc[dn].push(track)
function groupByDisc(initial) {
function inner(acc, track) {
var dn = track.disc_number - initial
if (acc[dn] == undefined) {
acc.push([track])
} else {
acc[dn].push(track)
}
return acc
}
return acc
return inner
}
export default {
......@@ -180,7 +182,7 @@ export default {
tracksResponse = await tracksResponse
this.object = albumResponse.data
this.object.tracks = tracksResponse.data.results
this.discs = this.object.tracks.reduce(groupByDisc, [])
this.discs = this.object.tracks.reduce(groupByDisc(this.object.tracks[0].disc_number), [])
this.isLoading = false
},
remove () {
......
......@@ -7,12 +7,12 @@
<channel-entries v-if="artist.channel && isSerie" :limit="50" :filters="{channel: artist.channel.uuid, ordering: '-creation_date'}">
</channel-entries>
<template v-else-if="discs && discs.length > 1">
<div v-for="(tracks, discNumber) in discs" :key="discNumber">
<div v-for="tracks in discs" :key="tracks.disc_number">
<div class="ui hidden divider"></div>
<play-button class="right floated mini inverted vibrant" :tracks="tracks"></play-button>
<translate
tag="h3"
:translate-params="{number: discNumber + 1}"
:translate-params="{number: tracks[0].disc_number}"
translate-context="Content/Album/"
>Volume %{ number }</translate>
<album-entries :tracks="tracks"></album-entries>
......
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