-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
cleanup: refactor getTagListSections to TagsOptionsListUtils #52287
cleanup: refactor getTagListSections to TagsOptionsListUtils #52287
Conversation
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.
looks good - just one question, might be fine but let me know!
* Sorts tags alphabetically by name. | ||
*/ | ||
function sortTags(tags: Record<string, PolicyTag | SelectedTagOption> | Array<PolicyTag | SelectedTagOption>) { | ||
// Use lodash's sortBy to ensure consistency with oldDot. |
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.
I see this is missing the const sortedTags = Array.isArray(tags) ? tags : Object.values(tags);
that was in the previous implementation - do we not need that check anymore?
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.
Yes, lodashSort works for arrays and objects out of the box so this check was never really needed. I added a unit test as well to confirm!
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.
LGTM!
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
aw shoot @hannojg I think merging your other PR gave this one conflicts. Can you take a look? Good to go once that's settled though! |
Yeah that will probably now happen with the other PRs, but thats okay, it was easier for review with all of these changes being separate PRs 😊 Just because you've already reviewed two of the PRs @dangrous do you think you have time to maybe check the other two PRs:
They are very similar to the two you've reviewed already, hence i thought it might be the quickest if you take a look. (if you have no time, then no worries!) |
Oops, just saw that the tests are failing now after the merge, hold on |
This reverts commit b327a98.
oh sure, I can look at those too, though it looks like Georgia already grabbed one of them |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/dangrous in version: 9.0.62-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.62-4 🚀
|
Explanation of Change
While working on performance fixes for the search over at this PR I touched the
OptionListUtils
a lot, specifically thegetOptions
andfilterOptions
functions.It occurs to me that the
getOptions
function became a god-function that serves a lot of different use-cases, has a lot of responsibilities and is quite coupled with a lot of other places in the code. The wholeOptionListUtils
is over 2.5k lines long and hard to understand.Right in the beginning of the
getOptions
function there are a few early return statements for certain cases. My plan is to refactor all those use-cases out into their own functions, as there is no use in adding aincludeXYC
parameter togetOptions
just to do:In this PR we moves the Tags to their own
TagsOptionsListUtils
.Related to:
Fixed Issues
$ #51954
PROPOSAL: #51954 (comment)
Tests
Offline tests
Same as testing
QA Steps
Same as testing
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
CleanShot.2024-11-09.at.09.36.03.mp4
Android: mWeb Chrome
CleanShot.2024-11-09.at.09.36.03.mp4
iOS: Native
CleanShot.2024-11-09.at.09.36.03.mp4
iOS: mWeb Safari
CleanShot.2024-11-09.at.09.36.03.mp4
MacOS: Chrome / Safari
CleanShot.2024-11-09.at.09.36.03.mp4
MacOS: Desktop
CleanShot.2024-11-09.at.09.36.03.mp4