From 9035c4e8f99478fc5f9898932682d518c8754812 Mon Sep 17 00:00:00 2001 From: Ash Date: Mon, 19 Feb 2024 11:57:07 +0000 Subject: [PATCH] refactor(core): rename for clarity --- .../core/studio/components/navbar/search/hooks/useSearch.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sanity/src/core/studio/components/navbar/search/hooks/useSearch.ts b/packages/sanity/src/core/studio/components/navbar/search/hooks/useSearch.ts index d58508107cd9..03dbec85f0e3 100644 --- a/packages/sanity/src/core/studio/components/navbar/search/hooks/useSearch.ts +++ b/packages/sanity/src/core/studio/components/navbar/search/hooks/useSearch.ts @@ -85,7 +85,7 @@ export function useSearch({ const maxFieldDepth = useSearchMaxFieldDepth() const strategy = useWorkspace().search.__experimental_strategy - const searchWeighted = useMemo( + const search = useMemo( () => createSearch( getSearchTypesWithMaxDepth(getSearchableOmnisearchTypes(schema), maxFieldDepth), @@ -128,7 +128,7 @@ export function useSearch({ iif( () => hasSearchableTerms({allowEmptyQueries, terms: request.terms}), // If we have a valid search, run async fetch, map results and trigger `onComplete` / `onError` callbacks - (searchWeighted(request.terms, request.options) as Observable).pipe( + (search(request.terms, request.options) as Observable).pipe( map((hits) => ({hits})), tap(({hits}) => onComplete?.(hits)), catchError((error) => { @@ -157,7 +157,7 @@ export function useSearch({ ) }, // eslint-disable-next-line react-hooks/exhaustive-deps -- @todo: add onComplete, onError and onStart to the deps list when it's verified that it's safe to do so - [allowEmptyQueries, searchWeighted], + [allowEmptyQueries, search], ) const handleSearch = useCallback(