A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix: only trigger search autocomplete on first search char
Mohamed Bassem92e352f3f6b5
diff --git a/apps/web/components/dashboard/search/useSearchAutocomplete.ts b/apps/web/components/dashboard/search/useSearchAutocomplete.tsindex ba55d51f..7ddfa39a 100644--- a/apps/web/components/dashboard/search/useSearchAutocomplete.ts+++ b/apps/web/components/dashboard/search/useSearchAutocomplete.ts@@ -263,6 +263,7 @@ const useTagSuggestions = (const { data: tagResults } = useTagAutocomplete({nameContains: debouncedTagSearchTerm,select: (data) => data.tags,+ enabled: parsed.activeToken.length > 0,});const tagSuggestions = useMemo<AutocompleteSuggestionItem[]>(() => {@@ -299,7 +300,9 @@ const useFeedSuggestions = (: "";const feedSearchTerm = stripSurroundingQuotes(feedSearchTermRaw);const normalizedFeedSearchTerm = feedSearchTerm.toLowerCase();- const { data: feedResults } = api.feeds.list.useQuery();+ const { data: feedResults } = api.feeds.list.useQuery(undefined, {+ enabled: parsed.activeToken.length > 0,+ });const feedSuggestions = useMemo<AutocompleteSuggestionItem[]>(() => {if (!shouldSuggestFeeds) {@@ -349,7 +352,9 @@ const useListSuggestions = (: "";const listSearchTerm = stripSurroundingQuotes(listSearchTermRaw);const normalizedListSearchTerm = listSearchTerm.toLowerCase();- const { data: listResults } = useBookmarkLists();+ const { data: listResults } = useBookmarkLists(undefined, {+ enabled: parsed.activeToken.length > 0,+ });const listSuggestions = useMemo<AutocompleteSuggestionItem[]>(() => {if (!shouldSuggestLists) {diff --git a/packages/shared-react/hooks/tags.ts b/packages/shared-react/hooks/tags.tsindex 617c6933..e1e7416f 100644--- a/packages/shared-react/hooks/tags.ts+++ b/packages/shared-react/hooks/tags.ts@@ -20,6 +20,7 @@ export function usePaginatedSearchTags(export function useTagAutocomplete<T>(opts: {nameContains: string;select?: (tags: ZTagListResponse) => T;+ enabled?: boolean;}) {return api.tags.list.useQuery({@@ -31,6 +32,7 @@ export function useTagAutocomplete<T>(opts: {select: opts.select,placeholderData: keepPreviousData,gcTime: opts.nameContains?.length > 0 ? 60_000 : 3_600_000,+ enabled: opts.enabled,},);}