Skip to content

Commit

Permalink
chore(interactive): reduce search execution (#1970)
Browse files Browse the repository at this point in the history
* chore(interactive): fix search duplicate execution

* chore: fix lint error
  • Loading branch information
Hongbusi committed Dec 12, 2022
1 parent f813195 commit 64a01d5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions interactive/components/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ const vFocus = {
watch(
() => route.query.s,
async () => {
input.value = String(route.query.s || '')
await excuteSearch()
async (val) => {
if (input.value === val)
return
input.value = String(val || '')
await executeSearch()
},
)
async function excuteSearch() {
async function executeSearch() {
if (input.value)
isSearching.value = true
try {
Expand All @@ -45,7 +47,7 @@ async function excuteSearch() {
throttledWatch(
input,
excuteSearch,
executeSearch,
{ throttle: 100, immediate: true },
)
Expand Down

0 comments on commit 64a01d5

Please sign in to comment.