fix: add stable sort to collection media pagination query#2444
Merged
Conversation
Adds a secondary ORDER BY on `id` to prevent duplicate and missing items when paginating collection media. Items sharing the same `addDate` could appear on multiple pages or be skipped entirely due to SQLite's non-deterministic row ordering for equal sort values. Closes #2443
…cate fetches Replace useState loading guards with useRef to prevent stale closure reads in scroll and fill-page effects, matching the working CollectionExclusions pattern.
enoch85
added a commit
that referenced
this pull request
Mar 1, 2026
PR #2444 - fix(ui): use ref-based guards in CollectionMediaPage to prevent duplicate fetches - Replace state-based fetch guards with refs to avoid React batching issues - Prevent duplicate API calls during pagination and collection media loading
… fetches The stale scroll handler closure in OverviewContent could trigger fetchData() concurrently with the fill-page effect, causing the same page to be fetched twice and subsequent pages to be skipped.
enoch85
added a commit
that referenced
this pull request
Mar 2, 2026
PR #2444 - fix(ui): add fetchingRef guard in Overview to prevent concurrent page fetches - Add ref-based guard to Overview component to prevent concurrent page fetches - Mirrors the same pattern applied to CollectionMediaPage in previous commit
Add a generation counter so that when a library switch invalidates an in-flight request, the old response cannot reset fetchingRef/loading state for the new library. Wrap the fetch in try/finally so a failed request also clears its own guards, preventing a pagination deadlock.
Contributor
|
🎉 This PR is included in version 3.2.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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
ORDER BY collection_media.id DESCto the collection media pagination query to ensure deterministic ordering across pagesaddDate(common when batch-added by rule handler) could appear on multiple pages or be skipped entirely due to SQLite's non-deterministic row ordering for equal sort valuesCloses #2443
Test plan
yarn buildpassesyarn test— all 494 tests pass