@@ -4,8 +4,6 @@ import { debounce } from 'perfect-debounce'
44// Pages that have their own local filter using ?q
55const pagesWithLocalFilter = new Set ( [ '~username' , 'org' ] )
66
7- const SEARCH_DEBOUNCE_MS = 250
8-
97export function useGlobalSearch ( place : 'header' | 'content' = 'content' ) {
108 const { settings } = useSettings ( )
119 const { searchProvider } = useSearchProvider ( )
@@ -29,14 +27,10 @@ export function useGlobalSearch(place: 'header' | 'content' = 'content') {
2927 // Syncs instantly when instantSearch is on, but only on Enter press when off
3028 const committedSearchQuery = useState < string > ( 'committed-search-query' , ( ) => searchQuery . value )
3129
32- const commitSearchQuery = debounce ( ( val : string ) => {
33- committedSearchQuery . value = val
34- } , SEARCH_DEBOUNCE_MS )
35-
3630 // This is basically doing instant search as user types
3731 watch ( searchQuery , val => {
3832 if ( settings . value . instantSearch ) {
39- commitSearchQuery ( val )
33+ committedSearchQuery . value = val
4034 }
4135 } )
4236
@@ -77,11 +71,10 @@ export function useGlobalSearch(place: 'header' | 'content' = 'content') {
7771 } )
7872 }
7973
80- const updateUrlQuery = debounce ( updateUrlQueryImpl , SEARCH_DEBOUNCE_MS )
74+ const updateUrlQuery = debounce ( updateUrlQueryImpl , 250 )
8175
8276 function flushUpdateUrlQuery ( ) {
8377 // Commit the current query when explicitly submitted (Enter pressed)
84- commitSearchQuery . cancel ( )
8578 committedSearchQuery . value = searchQuery . value
8679 // When instant search is off the debounce queue is empty, so call directly
8780 if ( ! settings . value . instantSearch ) {
0 commit comments