@@ -10,13 +10,6 @@ import { normalizeSearchParam } from '#shared/utils/url'
1010const route = useRoute ()
1111const router = useRouter ()
1212
13- const { searchProvider } = useSearchProvider ()
14- const searchProviderValue = computed (() => {
15- const p = normalizeSearchParam (route .query .p )
16- if (p === ' npm' || searchProvider .value === ' npm' ) return ' npm'
17- return ' algolia'
18- })
19-
2013// Preferences (persisted to localStorage)
2114const {
2215 viewMode,
@@ -33,12 +26,11 @@ const updateUrlPage = debounce((page: number) => {
3326 query: {
3427 ... route .query ,
3528 page: page > 1 ? page : undefined ,
36- p: searchProviderValue .value === ' npm' ? ' npm' : undefined ,
3729 },
3830 })
3931}, 500 )
4032
41- const searchQuery = useGlobalSearchQuery ()
33+ const { model : searchQuery, provider : searchProvider } = useGlobalSearch ()
4234const query = computed (() => searchQuery .value )
4335
4436// Track if page just loaded (for hiding "Searching..." during view transition)
@@ -131,7 +123,7 @@ const ALL_SORT_KEYS: SortKey[] = [
131123
132124// Disable sort keys the current provider can't meaningfully sort by
133125const disabledSortKeys = computed <SortKey []>(() => {
134- const supported = PROVIDER_SORT_KEYS [searchProviderValue .value ]
126+ const supported = PROVIDER_SORT_KEYS [searchProvider .value ]
135127 return ALL_SORT_KEYS .filter (k => ! supported .has (k ))
136128})
137129
@@ -173,14 +165,14 @@ const requestedSize = computed(() => {
173165 // When sorting by something other than relevance, fetch a large batch
174166 // so client-side sorting operates on a meaningful pool of matching results
175167 if (! isRelevanceSort .value ) {
176- const cap = EAGER_LOAD_SIZE [searchProviderValue .value ]
168+ const cap = EAGER_LOAD_SIZE [searchProvider .value ]
177169 return Math .max (base , cap )
178170 }
179171 return base
180172})
181173
182174// Reset to relevance sort when switching to a provider that doesn't support the current sort key
183- watch (searchProviderValue , provider => {
175+ watch (searchProvider , provider => {
184176 const { key } = parseSortOption (sortOption .value )
185177 const supported = PROVIDER_SORT_KEYS [provider ]
186178 if (! supported .has (key )) {
@@ -200,7 +192,7 @@ const {
200192 packageAvailability,
201193} = useSearch (
202194 query ,
203- searchProviderValue ,
195+ searchProvider ,
204196 () => ({
205197 size: requestedSize .value ,
206198 }),
0 commit comments