Skip to content

Implement faster pagination for library - #1441

Closed
anultravioletaurora wants to merge 1 commit into
mainfrom
feature/make-library-pagination-suck-less
Closed

Implement faster pagination for library#1441
anultravioletaurora wants to merge 1 commit into
mainfrom
feature/make-library-pagination-suck-less

Conversation

@anultravioletaurora

Copy link
Copy Markdown
Member

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:

  • Added a letterCursor object to the return value of useInfiniteQuery hooks for artists, albums, and tracks (useAlbumArtists, useAlbums, useTracks, and useArtistTracks). 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:

  • Implemented fetchArtistsCountBeforeLetter, fetchAlbumsCountBeforeLetter, and fetchTracksCountBeforeLetter utility functions. These use the Jellyfin API with the nameLessThan and enableTotalRecordCount options to efficiently determine how many items precede a given letter, avoiding unnecessary pagination. [1] [2] [3]

Query Hook Refactoring:

  • Refactored query hooks to extract and reuse queryKey arrays, facilitating their use in the new letterCursor objects and improving code clarity. [1] [2] [3] [4]

Documentation:

  • Added a comprehensive README (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:

  • Updated imports and type definitions to include the new LetterCursor type 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant