fix(api): request SortName field so fast scroll matches the sorted list#1619
Open
Thomas05000005 wants to merge 1 commit into
Open
fix(api): request SortName field so fast scroll matches the sorted list#1619Thomas05000005 wants to merge 1 commit into
Thomas05000005 wants to merge 1 commit into
Conversation
Adds SortName to the defaultFields constant used by the Jellyfin Items API queries. Without this field the server doesn't return BaseItemDto.sortName, so nameForSorting falls back to the raw name and the alphabet fast-scroller jumps to a letter that doesn't match where the item sits in the (server-side sorted) list. Closes finamp-app#978.
Thomas05000005
marked this pull request as ready for review
May 8, 2026 15:06
4 tasks
Author
|
Hi, Quick clarification, since #1623 was merged recently:
Without #1619, an album like "Les Bains Douches" keeps being sorted incorrectly because its server-side The two changes don't overlap (different files and code paths) and remain complementary. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the fast scroll alphabet jumping to the wrong letter for items whose display name and sort name differ. The bug reported in the issue (and reproduced by
@DanielDeurin the linked video) is "clickL→ jumps to Les Bains Douches even though the album is correctly sorted underBbecause its sort title is Bains Douches, Les".Closes #978
Root cause
music_screen_tab_view.dart'sscrollToLetteralready usesBaseItemDto.nameForSorting, andnameForSortingalready preferssortNameovernamewhen available. The actual problem is thatsortNamewas never being filled in by Jellyfin in the first place: thedefaultFieldsconstant injellyfin_api.dart:21didn't listSortName, so the Items API never returned it. WithsortName == null,nameForSortingfalls back toname(and the English-only "the / a / an" stripping), which doesn't match the server-side sort order for non-English titles like the "Les …" example, items withforcedSortName, or any user-customized sort key.The fix
Add
SortNametodefaultFields. That's the only change.nameForSortingalready does the right thing oncesortNameis populated.SortNameis documented as a validFieldsvalue directly inside this same file (the inline docstring on thegetItems@Query("Fields")parameter lists it), so this isn't introducing anything that needs a Jellyfin server-version gate.Why this is safe
fieldsargument are unaffected, and no field is removed.nameForSortingalready handlessortNamecorrectly; we're just feeding it data.flutter analyzereturns 0 new issues. Code formatted withdart format.Test plan
Manual checks to perform on a device (a library with at least one album whose
namestarts with a different letter than itssortNameis needed - French, Spanish, German articles, or any album with a customforcedSortNameworks):B)Bletter on the right-hand fast scroller - the list should now jump to that sectionLletter - should NOT jump to Les Bains Douches anymore (it should land on actualL*items)sortNamepopulated (this would catch any cache invalidation oversight, but I don't believe one is needed here)