Commit 2eced3c 1 parent 789e7cd commit 2eced3c Copy full SHA for 2eced3c
File tree 2 files changed +16
-9
lines changed
components/Common/Search/States
2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,9 @@ export const WithSearchBox: FC<SearchBoxProps> = ({ onClose }) => {
71
71
} , [ ] ) ;
72
72
73
73
useEffect (
74
- ( ) => debounce ( ( ) => search ( searchTerm ) , 1000 ) ,
74
+ ( ) => {
75
+ debounce ( ( ) => search ( searchTerm ) , 1000 ) ( ) ;
76
+ } ,
75
77
// we don't need to care about memoization of search function
76
78
// eslint-disable-next-line react-hooks/exhaustive-deps
77
79
[ searchTerm , selectedFacet ]
@@ -100,7 +102,12 @@ export const WithSearchBox: FC<SearchBoxProps> = ({ onClose }) => {
100
102
} ;
101
103
102
104
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 ,
104
111
...( searchResults ?. facets ?. siteSection ?. values ?? { } ) ,
105
112
} ;
106
113
Original file line number Diff line number Diff line change 1
1
type DebounceFunction < T = unknown > = ( ...args : Array < T > ) => void ;
2
2
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 ;
8
4
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 > ) => {
10
11
clearTimeout ( timeoutId ) ;
11
12
12
13
timeoutId = setTimeout ( ( ) => {
13
14
func ( ...args ) ;
14
15
} , delay ) ;
15
16
} ;
16
- } ;
You can’t perform that action at this time.
0 commit comments