Skip to content
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

(refactor) O3-2973: Remove dead code from the results viewer implementation #1751

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mccarthyaaron
Copy link
Contributor

Summary

Remove dead code from the results viewer implementation

Related Issue

https://openmrs.atlassian.net/browse/O3-2973

Copy link
Contributor

@chimanwadike chimanwadike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mccarthyaaron any idea this PR may be failing e2e tests?
Does it pass the e2e tests when executed on your local, please?

Comment on lines 44 to +45
const handleInputChange = useCallback(
(e) => {
setSearchTerm(searchTerm);
(searchTerm) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this change?
Changing the event to a string will not work, until you make change in the said onClick function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vasharma05 should I revert it to the original? Also help explain abit more as I haven't understood what you mean by the "the said onClick function". But this was my thought process: When the such term changes, the handleInputChange function is called with the search term passed as an argument. We then use that search term to get the filtered results. Previously 'e' was not being used anywhere in the handleInputChange function and I didn't understand why we are using an event as a parameter yet handleInputChange is being passed a string. Also though that maybe setting the search term( setSearchTerm(searchTerm) ) to the same value is kinda redudant. Thats how I thought about it. I am willing to be corrected

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think @vasharma05 mistakenly thought this is an input callback. It is actually being used in a useEffect and passed the searchTerm explicitly. But so this is all sort of nonsense. The code should probably just read

  useEffect(() => {
      const filteredData = roots.filter((node) => filterTreeNode(searchTerm, node));
      setTreeDataFiltered(filteredData);
  }, [searchTerm, root]);

The handleInputChange function can be gotten rid of entirely.

@@ -216,7 +215,7 @@ const TimelineDataGroup = ({ parent, subRows, xScroll, setXScroll, panelName, se
}
}, [handleScroll]);

const onIntersect = (entries, observer) => {
const onIntersect = (entries) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What on earth. This block does nothing. Time for git blame

Copy link
Contributor

@brandones brandones Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, @vasharma05 two years ago. He was new then. A bad review though.

@mccarthyaaron Please delete this whole block.

@brandones brandones changed the title (refactor) 03-2973: Remove dead code from the results viewer implementation (refactor) O3-2973: Remove dead code from the results viewer implementation Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants