Repository navigation
perf: Improvements to opening reports tab #82393
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
Changes from all commits
4064c1f
9fdcb2f
20bb8ae
cca9544
1905bb4
d9ae74c
b23dc72
618ff76
268f430
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import {activeAdminPoliciesSelector} from '@selectors/Policy'; | ||
| import {useCallback} from 'react'; | ||
| import type {OnyxCollection} from 'react-native-onyx'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {Policy} from '@src/types/onyx'; | ||
| import getEmptyArray from '@src/types/utils/getEmptyArray'; | ||
| import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; | ||
| import useOnyx from './useOnyx'; | ||
|
|
||
| function useActiveAdminPolicies() { | ||
| const {login} = useCurrentUserPersonalDetails(); | ||
| const selector = useCallback((policies: OnyxCollection<Policy>) => activeAdminPoliciesSelector(policies, login ?? ''), [login]); | ||
|
TMisiukiewicz marked this conversation as resolved.
Resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need ot use the useCallback here because of the rule we have for the selectors? Otherwise this should not be needed because of the react-compiler, right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exactly, not sure how to address it properly at this moment - for already compiling components we could skip the |
||
| const [activeAdminPolicies = getEmptyArray<Policy>()] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true, selector}, [login]); | ||
|
|
||
| return activeAdminPolicies; | ||
| } | ||
|
|
||
| export default useActiveAdminPolicies; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import {useMemo} from 'react'; | ||
| import {sortPoliciesByName} from '@libs/PolicyUtils'; | ||
| import useActiveAdminPolicies from './useActiveAdminPolicies'; | ||
| import useLocalize from './useLocalize'; | ||
|
|
||
| function useSortedActiveAdminPolicies() { | ||
| const {localeCompare} = useLocalize(); | ||
| const activeAdminPolicies = useActiveAdminPolicies(); | ||
| const sortedActiveAdminPolicies = useMemo(() => sortPoliciesByName(activeAdminPolicies, localeCompare), [activeAdminPolicies, localeCompare]); | ||
|
|
||
| return sortedActiveAdminPolicies; | ||
| } | ||
|
|
||
| export default useSortedActiveAdminPolicies; | ||
|
Comment on lines
+1
to
+14
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can remove this hook, instead adding a new prop to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do it this way, it would violate CLEAN-REACT-PATTERNS-1 rule
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops. Thanks for noticing me that 🤕 . All good then! |
||
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.
what does
shouldShowWorkspaceSearchInputhave to do with filters? looks like a piece that could be abstracted away.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.
Suprisingly it has a lot to do with filters

It displays if there is more than 12 items to display 😬