From 0bf76fdf8673968b66b725e8f70f9342cd7dc329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Sat, 7 Jan 2023 22:59:57 +0800 Subject: [PATCH] refactor: improve search UX --- composables/masto/search.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composables/masto/search.ts b/composables/masto/search.ts index 6b0f8722..21f4f723 100644 --- a/composables/masto/search.ts +++ b/composables/masto/search.ts @@ -56,6 +56,12 @@ export function useSearch(query: MaybeRef, options?: UseSearchOptions) { }))] } + watch(() => unref(query), () => { + if (!unref(query) || !isMastoInitialised.value) + return + loading.value = true + }) + debouncedWatch(() => unref(query), async () => { if (!unref(query) || !isMastoInitialised.value) return @@ -78,7 +84,7 @@ export function useSearch(query: MaybeRef, options?: UseSearchOptions) { appendResults(nextResults.value, true) loading.value = false - }, { debounce: 500 }) + }, { debounce: 300 }) const next = async () => { if (!unref(query) || !isMastoInitialised.value || !paginator)