11import { useMemo } from 'react' ;
2- import { mergeCardListWithWorkspaceFeeds } from '@libs/CardUtils' ;
32import { buildSearchQueryJSON } from '@libs/SearchQueryUtils' ;
43import { createTypeMenuSections } from '@libs/SearchUIUtils' ;
5- import CONST from '@src/CONST' ;
64import ONYXKEYS from '@src/ONYXKEYS' ;
75import useOnyx from './useOnyx' ;
86
@@ -11,16 +9,14 @@ import useOnyx from './useOnyx';
119 * currently focused search, based on the hash
1210 */
1311const useSearchTypeMenuSections = ( hash = 0 ) => {
14- const [ session ] = useOnyx ( ONYXKEYS . SESSION , { canBeMissing : false } ) ;
12+ const [ currentUserLoginAndAccountID ] = useOnyx ( ONYXKEYS . SESSION , { selector : ( session ) => ( { email : session ?. email , accountID : session ?. accountID } ) , canBeMissing : false } ) ;
13+ const [ allFeeds ] = useOnyx ( ONYXKEYS . COLLECTION . SHARED_NVP_PRIVATE_DOMAIN_MEMBER , { canBeMissing : true } ) ;
1514 const [ allPolicies ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { canBeMissing : true } ) ;
16- const [ userCardList ] = useOnyx ( ONYXKEYS . CARD_LIST , { canBeMissing : true } ) ;
17- const [ workspaceCardFeeds ] = useOnyx ( ONYXKEYS . COLLECTION . WORKSPACE_CARDS_LIST , { canBeMissing : true } ) ;
1815
19- const hasCardFeed = useMemo ( ( ) => {
20- return Object . keys ( mergeCardListWithWorkspaceFeeds ( workspaceCardFeeds ?? CONST . EMPTY_OBJECT , userCardList ) ) . length > 0 ;
21- } , [ userCardList , workspaceCardFeeds ] ) ;
22-
23- const typeMenuSections = useMemo ( ( ) => createTypeMenuSections ( session , hasCardFeed , allPolicies ) , [ allPolicies , hasCardFeed , session ] ) ;
16+ const typeMenuSections = useMemo (
17+ ( ) => createTypeMenuSections ( currentUserLoginAndAccountID ?. email , currentUserLoginAndAccountID ?. accountID , allFeeds , allPolicies ) ,
18+ [ currentUserLoginAndAccountID ?. email , currentUserLoginAndAccountID ?. accountID , allPolicies , allFeeds ] ,
19+ ) ;
2420
2521 const currentSearch = useMemo ( ( ) => {
2622 const flatMenuItems = typeMenuSections . map ( ( section ) => section . menuItems ) . flat ( ) ;
0 commit comments