-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Sort group member avatar icons correctly to avoid avatar rearranging upon receiving backend response #25416
Merged
Merged
Sort group member avatar icons correctly to avoid avatar rearranging upon receiving backend response #25416
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
990932d
sort group member avatar icons correctly
honnamkuan 10bebee
Merge remote-tracking branch 'origin/main' into 23364
honnamkuan 83d5baa
Merge branch 'main' into 23364
honnamkuan fd1f659
sort avatar icons by user displayName/login
honnamkuan e70c1e9
update comment
honnamkuan bcaa077
Merge branch 'main' into 23364
honnamkuan 2996bf5
Merge remote-tracking branch 'origin/main' into 23364
honnamkuan 4d93923
refactor lodashGet usages to const
honnamkuan 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 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
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.
@honnamkuan Can you confirm if chaining the sortBy won't have side effects? Also quick question, would it make sense to use this instead?
let me know your thoughts.
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.
@mananjadhav thanks for the feedbacks!
I definitely agree that
_.orderBy(participantDetails, [2, 1, 0]);
would looks cleaner, however_.orderBy
is actually part of the Lodash utility function, it is not available within Underscore.js which Expensify App uses.To confirm that, I tried out using
orderBy
and verified that I am gettingUncaught TypeError: underscore__WEBPACK_IMPORTED_MODULE_2__.default.orderBy is not a function
in the consoleUnderscore
sortBy
produce stable sorted copy of array, hence no unintended side effects and can safely be included in chained processing.I can confirm that chaining
sortBy
is working well, and the approach is also recommended in various SO threads when it comes to sorting using on multiple sub-elements/attributese.g. https://stackoverflow.com/a/35612266
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.
@honnamkuan Expensify App uses lodash.
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.
@mananjadhav you are right that Expensify App uses the lodash package.
However the contributing guides STYLE.md says
Therefore, all
_
imports in the project are coming fromimport _ from 'underscore';
e.g.
App/src/libs/ReportUtils.js
Line 1 in c435734
Having said that, I am happy to change it to use lodash orderBy if you think that is the better approach here, your advice will be much appreciated.
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.
No. Thanks this works. I just went through the SO thread. I will test this shortly.