Skip to content

Commit da441a1

Browse files
committed
fix: remove unnecessary debounce
1 parent a21b137 commit da441a1

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

app/composables/useGlobalSearch.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { debounce } from 'perfect-debounce'
44
// Pages that have their own local filter using ?q
55
const pagesWithLocalFilter = new Set(['~username', 'org'])
66

7-
const SEARCH_DEBOUNCE_MS = 250
8-
97
export 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

Comments
 (0)