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

Feat filters persistence #1437

Closed
wants to merge 9 commits into from
Closed

Conversation

ladeirarodolfo
Copy link
Collaborator

@ladeirarodolfo ladeirarodolfo commented Feb 11, 2020

PR Checklist

  • Brief description of changes
  • Links to any relevant issues
  • Required status checks are passing
  • User cases if changes impact the user's experience
  • @mention a maintainer to request a review

It includes

  • It persists filters/sort/rowsPerPage/pageNum on sessionStorage
  • Clear filters button added
  • When/to rendering fetch data there is at least one re-render process less than actual impl.
  • Ability to set up field to be clearable. I.e there will be a x icon to clear that field up. Currently added to search all field

Screenshots

OHIF-Viewer-3

@codecov
Copy link

codecov bot commented Feb 11, 2020

Codecov Report

Merging #1437 into master will decrease coverage by 0.06%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1437      +/-   ##
==========================================
- Coverage   12.03%   11.97%   -0.07%     
==========================================
  Files         272      273       +1     
  Lines        6969     7013      +44     
  Branches     1311     1314       +3     
==========================================
+ Hits          839      840       +1     
- Misses       4965     5005      +40     
- Partials     1165     1168       +3     
Flag Coverage Δ
#core 17.12% <33.33%> (+0.01%) ⬆️
#viewer 0.37% <0.00%> (-0.01%) ⬇️
Impacted Files Coverage Δ
platform/core/src/utils/getContentFromArrayMap.js 33.33% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06075ec...525122a. Read the comment docs.

 Conflicts:
	platform/core/src/utils/index.js
	platform/core/src/utils/index.test.js
@cypress
Copy link

cypress bot commented Feb 13, 2020



Test summary

24 1 0 0


Run details

Project Viewers
Status Failed
Commit c2f4709
Started Feb 13, 2020 9:13 PM
Ended Feb 13, 2020 9:17 PM
Duration 03:59 💡
OS Linux Debian - 9.9
Browser Chrome 76

View run in Cypress Dashboard ➡️


Failures

cypress/integration/visual-regression/PercyCheckOHIFUserPreferences.spec.js Failed
1 Visual Regression - OHIF User Preferences > Study Viewer Page > checks new hotkeys for "Next" and "Previous" Image on Viewport

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@dannyrb
Copy link
Member

dannyrb commented Feb 14, 2020

We didn't run Visual Regression Tests after @galelis's Hotkeys update, so this test likely just needs tweaked. The Percy flavored Cypress tests aren't really trying to "catch" anything, they just use Cypress to setup the app for reproducible screen shot states.

image

That error and the file that it's originating should be enough to resolve it, as it should just be a string comparison/check.

@dannyrb dannyrb self-requested a review February 14, 2020 03:00

const memoizedList = useMemo(() => {
return (
<StudyList
Copy link
Member

Choose a reason for hiding this comment

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

Don't component only re-render if one of their props has updated? Does useMemo save us some CPU here? (why not wrap all component in useMemo?)

fetchStudies(newStudyListSessionProps);
},
[studyListSessionProps]
);
Copy link
Member

Choose a reason for hiding this comment

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

Some repeat code here for setting these. Would it make more sense to shift from individual pieces of state to a "filter + sort" object, and then handle all of the callback/session/updates in once place?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah we could, but to avoid having component re-render multiple times and considering things might change simultaneously (i.e page+filter, sort+something else...) this implementation ensure unicity and scalability. We can loop through it for any change if you desire to

displaySize,
server,
]
[server, displaySize]
Copy link
Member

Choose a reason for hiding this comment

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

Does useCallback net us much of a benefit here? Is the readability loss worth the performance gain?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

useCallback brings us mainly two things:

  • performance
  • unicity

From my understanding, considering React`s new way of coding, this method is not less readable, is it? We can change, add comments :D, your call my friend

setSearchStatus({ error: null, isSearchingForStudies: false });
}, FETCH_DEBOUNCE_TIME),
[server, displaySize]
);
Copy link
Member

Choose a reason for hiding this comment

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

We could leverage our useDebounce on a more complex filters + sort object. When the debounce elapses, we could fetchData and store/cache the filter + sort in session storage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes we could by to preserve the current user experience flow its kept as its.
To do such change the effort will be higher.
Currently the flow is: child event (ex: key type on filter field), tell parent, do some stuff on parent, update child. I.e parent is totally responsible to process things and update child. With such implementation the updating of child is preserved, session always has the real data, but fetch is called only sometimes..

Totally makes sense to be the way you mentioned but, there are two problems I see:

  • Integration between different child. I.e. pieces need to be in sync: When fetching list and page must be updated, ...
  • It will cause some refactoring on child end.

...currentProps,
...newProps,
};
};
Copy link
Member

Choose a reason for hiding this comment

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

The "new props" don't really conflict with currentProps. There's no cache overlap?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess I ddint get your point here.

let inputType = fieldInputType;
if (clearable && inputType === 'text') {
inputType = 'search';
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I follow what's going on here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At user experience: add x icon to remove text on a input field
At dev level: use inputType as search when field is clearable

@sedghi sedghi removed the Story 🙌 label Jan 11, 2023
@sedghi sedghi changed the base branch from master to v2-legacy June 19, 2023 13:24
@sedghi
Copy link
Member

sedghi commented Jun 19, 2023

base has changed, read more here #3477

@sedghi
Copy link
Member

sedghi commented Oct 3, 2023

This is an unfinished but valuable work, we should include it in v3

@jbocce
Copy link
Contributor

jbocce commented Oct 27, 2023

This PR is being closed in favour of this new PR #3749 which targets the most current master branch. Thanks @ladeirarodolfo for the inspiration, ideas, code and unit tests.

@jbocce jbocce closed this Oct 27, 2023
@sedghi sedghi added fixed-in-dev-await-release This issue is fixed in master (viewer-dev) but we are pending testing for release (viewer.ohif.org) and removed v2-legacy OHIF v2 labels Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed-in-dev-await-release This issue is fixed in master (viewer-dev) but we are pending testing for release (viewer.ohif.org)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants