Repository navigation
Paginate live to-do searches instead of rendering every cached row #100941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mountiny
merged 25 commits into
Expensify:main
from
callstack-internal:paginate-live-search-offline
Sep 25, 2026
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
7ad4cba
Paginate live to-do searches
TMisiukiewicz 31b41a4
Merge remote-tracking branch 'origin/main' into paginate-live-search-…
TMisiukiewicz 4c65f8b
Keep the live row cap monotonic
TMisiukiewicz b9c6e4f
Resume live pagination after the last revealed row
TMisiukiewicz 2ebf402
Cap selection data to the rendered rows
TMisiukiewicz ad85902
Cap the offline reveal at the live row limit
TMisiukiewicz 0231de5
Restart a to-do page request stranded by a reload
TMisiukiewicz 4495c26
Test the live row cap
TMisiukiewicz 22baeb2
Merge origin/main into paginate-live-search-offline
TMisiukiewicz 2ed0d9d
Remove duplicate shouldUseNarrowLayout declaration
TMisiukiewicz b212c4b
Own live pagination with local state, force snapshot isLoading off
TMisiukiewicz f181fc8
Retry live pagination on failure
TMisiukiewicz e3adfc0
Enable local pagination when live search reaches server limit
TMisiukiewicz 8f6f84b
Test live to-do search pagination with offline handling
TMisiukiewicz 98770b7
Merge remote-tracking branch 'origin/main' into paginate-live-search-…
TMisiukiewicz 5a072e2
Keep selected, highlighted and adopted live rows in view under the cap
TMisiukiewicz 97f37cc
Page live searches from the answered cursor and key the in-flight fla…
TMisiukiewicz 08b0eef
Keep the live cap's reveal rule inside useLiveRowLimit
TMisiukiewicz 7bbf39d
Replace live row cap type assertions with the group row type guard
TMisiukiewicz a7aa048
Revert no-op changes to useSearchPageSetup
TMisiukiewicz 980b2b9
Wait for a request to go out before paging in cached to-do rows locally
TMisiukiewicz ae8a48f
Clear the adopted live page flag once that page settles
TMisiukiewicz 143e8cf
Retry a failed live page only on an end the user scrolled to
TMisiukiewicz d364d3c
Test a live page landing after a remount rewound the snapshot
TMisiukiewicz cbb11ed
Mark a scrolled-to end from visible rows, not the worklet scroll handler
TMisiukiewicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import CONST from '@src/CONST'; | ||
|
|
||
| import {useState} from 'react'; | ||
|
|
||
| type LiveRowLimit = { | ||
| liveRowLimit: number; | ||
|
|
||
| /** Offset of the last page the server answered. Unlike the snapshot offset, which every search() caller rewrites, it only moves forward. */ | ||
| answeredOffset: number; | ||
|
|
||
| /** Shows one more page of live rows without the server, for when it has no pages left. */ | ||
| revealNextPage: () => void; | ||
| }; | ||
|
|
||
| /** Row cap for a live (to-do) search. Reset rides on `<Search key={queryJSON.hash}>` remounting, so there is no reset here. */ | ||
| function useLiveRowLimit(offset = 0, hasUnconfirmedPage = false): LiveRowLimit { | ||
| // offset is written when the request fires, so a page still running or failed there only confirms the one before it | ||
| const confirmedOffset = Math.max(0, hasUnconfirmedPage ? offset - CONST.SEARCH.RESULTS_PAGE_SIZE : offset); | ||
|
|
||
| // a refresh rewinds offset to 0, but the pages past it already answered and their rows are still in Onyx | ||
| const [answeredOffset, setAnsweredOffset] = useState(confirmedOffset); | ||
| if (answeredOffset < confirmedOffset) { | ||
| setAnsweredOffset(confirmedOffset); | ||
| } | ||
| const currentAnsweredOffset = Math.max(answeredOffset, confirmedOffset); | ||
| const answeredRows = currentAnsweredOffset + CONST.SEARCH.RESULTS_PAGE_SIZE; | ||
|
|
||
| const [revealedRows, setRevealedRows] = useState(answeredRows); | ||
| if (revealedRows < answeredRows) { | ||
| setRevealedRows(answeredRows); | ||
| } | ||
|
|
||
| const revealNextPage = () => setRevealedRows((rows) => rows + CONST.SEARCH.RESULTS_PAGE_SIZE); | ||
|
|
||
| return {liveRowLimit: Math.max(revealedRows, answeredRows), answeredOffset: currentAnsweredOffset, revealNextPage}; | ||
| } | ||
|
|
||
| export default useLiveRowLimit; |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.