-
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
ignore periods on search #8375
Merged
stitesExpensify
merged 5 commits into
Expensify:main
from
mateusbra:ignorePeriodsOnSearch
Apr 13, 2022
Merged
ignore periods on search #8375
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b6610ba
ignore periods on search
mateusbra bd09df6
removed unnecessary push to searchTerms and solved edge case
mateusbra 1b2e519
added test unit in order to cover the search with results containing …
mateusbra 2d5e311
added tests for userToInvite
mateusbra cd963aa
refactor noOptions, noOptionsMatchExactly
mateusbra 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.
thought: It might help readability if we just extract this whole if block to a method like
canAddUserToInvite()
? It looks pretty crazy and we are duplicating some logic for the login options.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 have this feeling too.
What do you think of changing the if block to:
adding the method:
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
thinking A =
(!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login === searchValue.toLowerCase()))
and B =
(recentReportOptions.length + personalDetailsOptions.length) === 0
We have A && (A || B), its a redundant logic, we could change to A.
A && (A || B) = A , so we could discard the B logic keeping the same behavior:
let me know what you guys think before I push some changes to it
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.
Yeah that's a lot of variables for a method, but cleaning it up would be an improvement. We could also maybe making it less of a giant ternary that is hard to make sense out of and use extra variables and if statements (but let's pause that for a second).
As for the redundancy, I agree with the assessment that
B
would be unneeded - but is the proposal to remove the code to check for available options? Why was the change added in the first place?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.
this change was added in order to prevent this edge case @Santhosh-Sellavel found on #8007 (comment) , so we needed to show user to invite even when it doesn't found a result from search(when lenghts == 0)
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.
@marcaaron nice one! may I commit all thoses changes?
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.
Yep!
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.
Sorry, @marcaaron for the confusion.
You are right,
The confusion originated from my suggestions here. #8375 (comment) those were two quick suggestions.
But we would really avoided this conversation if @mateusbra went with first suggestion, because this occurs only when search has dot.
But this is the better & simpler solution, unfortunately we both missed to foresee
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.
Sorry @Santhosh-Sellavel I thought the second sugestion you proposed was better 😅, but now I think the misunderstoods were solved.
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 commited the changes, if you think its better to use the first suggestion from #8375 (comment) please tell me.