File tree Expand file tree Collapse file tree
components/Common/Search/States Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,7 +71,9 @@ export const WithSearchBox: FC<SearchBoxProps> = ({ onClose }) => {
7171 } , [ ] ) ;
7272
7373 useEffect (
74- ( ) => debounce ( ( ) => search ( searchTerm ) , 1000 ) ,
74+ ( ) => {
75+ debounce ( ( ) => search ( searchTerm ) , 1000 ) ( ) ;
76+ } ,
7577 // we don't need to care about memoization of search function
7678 // eslint-disable-next-line react-hooks/exhaustive-deps
7779 [ searchTerm , selectedFacet ]
@@ -100,7 +102,12 @@ export const WithSearchBox: FC<SearchBoxProps> = ({ onClose }) => {
100102 } ;
101103
102104 const facets : Facets = {
103- all : searchResults ?. count ?? 0 ,
105+ all : searchResults ?. facets
106+ ? Object . values ( searchResults ?. facets . siteSection . values ) . reduce (
107+ ( a , b ) => a + b ,
108+ 0
109+ )
110+ : 0 ,
104111 ...( searchResults ?. facets ?. siteSection ?. values ?? { } ) ,
105112 } ;
106113
Original file line number Diff line number Diff line change 11type DebounceFunction < T = unknown > = ( ...args : Array < T > ) => void ;
22
3- export const debounce = < T extends DebounceFunction > (
4- func : T ,
5- delay : number
6- ) : ( ( ...args : Parameters < T > ) => void ) => {
7- let timeoutId : NodeJS . Timeout ;
3+ let timeoutId : NodeJS . Timeout ;
84
9- return ( ...args : Parameters < T > ) => {
5+ export const debounce =
6+ < T extends DebounceFunction > (
7+ func : T ,
8+ delay : number
9+ ) : ( ( ...args : Parameters < T > ) => void ) =>
10+ ( ...args : Parameters < T > ) => {
1011 clearTimeout ( timeoutId ) ;
1112
1213 timeoutId = setTimeout ( ( ) => {
1314 func ( ...args ) ;
1415 } , delay ) ;
1516 } ;
16- } ;
You can’t perform that action at this time.
0 commit comments