Add pagination to NewChatPage#88452
Open
sharabai wants to merge 2 commits into
Open
Conversation
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.
Explanation of Change
Note
#87881 must be merged first
Add pagination to
NewChatPage(usePaginatedData)Problem: Pagination used to live inside
SelectionListWithSections. The screen prepared all personal details up front and the list just revealed more already-computed rows on scroll — purely visual, no real work saved. The screen had no control or visibility over it; you'd normally expect pagination at the data-preparation level, and the data flow inNewChatPageis complicated enough that it was easy to miss that pagination wasn't happening there at all. The new list doesn't carry this forward, so New Chat lost even the visual pagination while still processing the full list.Approach: Move pagination up to the screen (
NewChatPage) using a small, generic hook (usePaginatedData), applied at two points:Important
the two usages serve different purposes and are mutually exclusive:
Why: Pagination at the list level hid both work and intent. Owning it at the screen with a dedicated hook makes the data-prep flow traceable and controllable — on initial load (and whenever the user is not searching) "seeing pagination" now actually matches "pagination is happening."
Note
A purely visual pagination is still kept while the user is searching — search itself runs against the full dataset, but filtered rows are still fed into the list in chunks so the list doesn't mount everything at once.
Sort and dedupe before slicing (alphabetical pagination)
Problem: With pagination at the screen, page 1 was the first
PAGINATION_SIZEofObject.values(personalDetails)—accountIDorder, not alphabetical.filterAndOrderOptionsthen alphabetized only that arbitrary slice, soloadMorecould reveal a name that sorted earlier than already-visible rows. Imported phone contacts had the same issue; an Onyx-PD/contact login overlap also wasted page slots before the late dedupe inOptionsListUtilsstripped one.Approach: Dedupe + alphabetically sort the union of Onyx personal details and imported phone contacts upstream of pagination, in a small pure helper (
mergeAndSortPersonalDetailsWithContacts). Dedupe key:addSMSDomainIfPhoneNumber(login).toLowerCase(). Onyx PDs are spread first, so on collision the real-accountIDcopy wins over the optimistic contact copy. The latepersonalDetails.concat(contacts)is removed (contacts are already merged upstream). While here,orderPersonalDetailsOptionsis generic-ised and its sort key aligned withpersonalDetailsComparator, so the upstream sort agrees with the heap re-sort insidegetValidOptions.Why: A paginated slice should match the user's mental model of "first page." Sorting + deduping upstream makes page 1 the alphabetical prefix and
loadMorestrictly append-only under a stable data snapshot.Performance gains on opening New Chat
With this change, opening
NewChatPageon accounts with a large contact list is noticeably faster — +75.88 ms(+22.2%) without the pagination.
Measured by forcing
skipPagination: trueon the firstusePaginatedDatausage (the one before data preparation) to simulate the previous behavior, and comparing against the current code with pagination enabled.Fixed Issues
$ #86089
PROPOSAL:
Tests
Load-flow pagination (initial open)
Visual pagination while searching
Sort + dedupe correctness
accountIDhas an early alphabetical name (e.g. "Aaron")Offline tests
QA Steps
Same as tests
Offline tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
pagination.mp4