Debounce search

This commit is contained in:
Jon Staab
2025-11-25 11:55:32 -08:00
parent 64c77cfd13
commit 229d92055f
4 changed files with 18 additions and 15 deletions
+11 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts">
import {onMount} from "svelte"
import {debounce} from "throttle-debounce"
import {createScroller, isMobile} from "@lib/html"
import {profileSearch} from "@welshman/app"
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
@@ -11,9 +12,18 @@
let term = $state("")
let limit = $state(10)
let pubkeys = $state($bootstrapPubkeys)
let element: Element | undefined = $state()
const pubkeys = $derived(term ? $profileSearch.searchValues(term) : $bootstrapPubkeys)
const search = debounce(200, (term: string) => {
if (term) {
pubkeys = $profileSearch.searchValues(term)
} else {
pubkeys = $bootstrapPubkeys
}
})
$effect(() => search(term))
onMount(() => {
const scroller = createScroller({