Repository navigation
Replace PERSONAL_AND_WORKSPACE_CARD_LIST derived value with a memoized useOnyxState hook - #94
Draft
elirangoshen wants to merge 3 commits into
Draft
elirangoshen wants to merge 3 commits into
elirangoshen wants to merge 3 commits into
Conversation
…d useOnyxState hook
useOnyxState's default selectorEquality deep-compares the output for every mounted consumer, so a real card change cost one full compare of the merged list per consumer. select() now compares each selector's output once and keeps the previous object when equal, and the hook compares by identity. Also drops the collection-type cast that Onyx no longer needs.
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.
Explanation of Change
This builds on the unmerged
useOnyxStatefrom the Onyx store work and targetsfeature/onyx-store-useonyxstate-recut(Expensify#104690).PERSONAL_AND_WORKSPACE_CARD_LISTis computed by OnyxDerived fromCARD_LISTand everyWORKSPACE_CARDS_LISTfeed. It runs outside React and writes the merged list back into Onyx and to disk on every write to either key, even when nothing changed. All its consumers are Search surfaces.This replaces the derived value with a
usePersonalAndWorkspaceCardListhook onuseOnyxStateover the same two keys:selectorEqualitywould otherwise deep-compare the full list again for every mounted consumer on every write.All 7 consumers use the hook. The config, its key and its type are removed. The persisted row is left on disk, as with the
TODOSremoval. Neither key is redirected to the Search snapshot, so Search keeps reading live data.A new reassure test mounts
useSearchSections,useFilterFeedData,useFilterCardValueanduseAdvancedSearchFilters3 times each. 10 writes with 9,000 cards, mean ms:useOnyxWith a normal number of cards the difference is 1 to 3 ms. On the iOS simulator (dev build, account with 21 cards),
ManualOpenSearchRouteris 1946 ms on base and 1895 ms on this branch, which is within noise.Fixed Issues
$ https://github.com/callstack-internal/expensify-issues/issues/3080
PROPOSAL:
Tests
card:in the search bar. Verify the autocomplete suggests your personal card and the workspace cards.Offline tests
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, 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.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