mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
fix(subsonic): don't return empty disctitles for a single disc album
See https://support.symfonium.app/t/hide-disc-header-for-albums-with-only-1-disc/6877/1 Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
57d3be8604
commit
ee18489b85
2 changed files with 21 additions and 0 deletions
|
@ -347,6 +347,9 @@ func buildDiscSubtitles(a model.Album) []responses.DiscTitle {
|
|||
for num, title := range a.Discs {
|
||||
discTitles = append(discTitles, responses.DiscTitle{Disc: int32(num), Title: title})
|
||||
}
|
||||
if len(discTitles) == 1 && discTitles[0].Title == "" {
|
||||
return nil
|
||||
}
|
||||
sort.Slice(discTitles, func(i, j int) bool {
|
||||
return discTitles[i].Disc < discTitles[j].Disc
|
||||
})
|
||||
|
|
|
@ -82,6 +82,24 @@ var _ = Describe("helpers", func() {
|
|||
Expect(buildDiscSubtitles(album)).To(BeNil())
|
||||
})
|
||||
|
||||
It("should return nil when album has only one disc without title", func() {
|
||||
album := model.Album{
|
||||
Discs: map[int]string{
|
||||
1: "",
|
||||
},
|
||||
}
|
||||
Expect(buildDiscSubtitles(album)).To(BeNil())
|
||||
})
|
||||
|
||||
It("should return the disc title for a single disc", func() {
|
||||
album := model.Album{
|
||||
Discs: map[int]string{
|
||||
1: "Special Edition",
|
||||
},
|
||||
}
|
||||
Expect(buildDiscSubtitles(album)).To(Equal([]responses.DiscTitle{{Disc: 1, Title: "Special Edition"}}))
|
||||
})
|
||||
|
||||
It("should return correct disc titles when album has discs with valid disc numbers", func() {
|
||||
album := model.Album{
|
||||
Discs: map[int]string{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue