daneren2005 / Subsonic

Home of the DSub Android client fork
GNU General Public License v3.0
582 stars 162 forks source link

Fix album sort with duplicate track numbers #1112

Closed mvn23 closed 2 years ago

mvn23 commented 2 years ago

For some reason some of my folders contain duplicate track numbers. Some albums even have all track numbers set to 1. In this case, DSub reverses the sort order of these albums (a-z becomes z-a) so if the actual track numbers are at the start of the file name the album is actually reversed.

With this PR, we default to sorting by track name if the track numbers are not set or identical. In other cases, behavior remains unchanged.

mvn23 commented 2 years ago

Is this being watched @daneren2005 ?

daneren2005 commented 2 years ago

Yes it is I keep forgetting to review this from a computer

daneren2005 commented 2 years ago

Looks good except can we keep the same formatting style?

ie: you changed to

if(lhsTrack == rhsTrack) {
    return collator.compare(lhs.getTitle(), rhs.getTitle());
}
if(lhsTrack != null && rhsTrack != null) {

but it should be

if(lhsTrack == rhsTrack) {
    return collator.compare(lhs.getTitle(), rhs.getTitle());
} else if(lhsTrack != null && rhsTrack != null) {

I think with the formatting change I would be good to merge in

mvn23 commented 2 years ago

Thanks for the review! No problem! I guess the python programmer in me sort of autocorrected that (most python testing suites consider else-after-return an issue), but of course we're using java here. I am currently on vacation, but as soon as I can find a moment I will prepare another commit.