1
0
Fork 0

fix(docsearch): don't request Algolia on start screen

This commit is contained in:
François Chalifour 2020-04-06 18:18:20 +02:00
parent bf86a1d09f
commit e6614359ab

View file

@ -104,6 +104,35 @@ export function DocSearch({
setState(state as any);
},
getSources({ query, state, setContext, setStatus }) {
if (!query) {
return [
{
onSelect({ suggestion }) {
saveRecentSearch(suggestion);
onClose();
},
getSuggestionUrl({ suggestion }) {
return suggestion.url;
},
getSuggestions() {
return recentSearches.getAll();
},
},
{
onSelect({ suggestion }) {
saveRecentSearch(suggestion);
onClose();
},
getSuggestionUrl({ suggestion }) {
return suggestion.url;
},
getSuggestions() {
return favoriteSearches.getAll();
},
},
];
}
return getAlgoliaHits({
searchClient,
queries: [
@ -174,35 +203,6 @@ export function DocSearch({
});
}
if (!query) {
return [
{
onSelect({ suggestion }) {
saveRecentSearch(suggestion);
onClose();
},
getSuggestionUrl({ suggestion }) {
return suggestion.url;
},
getSuggestions() {
return recentSearches.getAll();
},
},
{
onSelect({ suggestion }) {
saveRecentSearch(suggestion);
onClose();
},
getSuggestionUrl({ suggestion }) {
return suggestion.url;
},
getSuggestions() {
return favoriteSearches.getAll();
},
},
];
}
return Object.values<DocSearchHit[]>(sources).map(items => {
return {
onSelect({ suggestion }) {