Implement faster pagination for library - #1441
Closed
anultravioletaurora wants to merge 1 commit into
Closed
Conversation
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.
This pull request adds support for efficient A-Z (letter) navigation in paginated lists of artists, albums, and tracks by introducing a "letter cursor" mechanism to each entity's React Query hook. This allows the A-Z scroller component to jump directly to the page containing a tapped letter, rather than paginating through every page sequentially. The implementation includes new utility functions to quickly count the number of items before a given letter, updated hook return values, and thorough documentation of the pattern.
The most important changes are:
A-Z Scroller Integration for Infinite Lists:
letterCursorobject to the return value ofuseInfiniteQueryhooks for artists, albums, and tracks (useAlbumArtists,useAlbums,useTracks, anduseArtistTracks). This object provides methods to fetch a specific page and to count items before a given letter, enabling instant jumps in the A-Z scroller. [1] [2] [3] [4]New Utility Functions for Counting Items Before a Letter:
fetchArtistsCountBeforeLetter,fetchAlbumsCountBeforeLetter, andfetchTracksCountBeforeLetterutility functions. These use the Jellyfin API with thenameLessThanandenableTotalRecordCountoptions to efficiently determine how many items precede a given letter, avoiding unnecessary pagination. [1] [2] [3]Query Hook Refactoring:
queryKeyarrays, facilitating their use in the newletterCursorobjects and improving code clarity. [1] [2] [3] [4]Documentation:
src/api/queries/README.md) describing the folder structure, infinite query design, and the new letter cursor mechanism, including usage details and rationale.Type and Import Updates:
LetterCursortype and utility functions where needed in the query hooks. [1] [2] [3]These changes collectively improve the user experience for navigating large music libraries by making A-Z jumps instantaneous and memory-efficient.