Skip to content

Commit e661435

Browse files
fix(docsearch): don't request Algolia on start screen
1 parent bf86a1d commit e661435

1 file changed

Lines changed: 29 additions & 29 deletions

File tree

src/DocSearch.tsx

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,35 @@ export function DocSearch({
104104
setState(state as any);
105105
},
106106
getSources({ query, state, setContext, setStatus }) {
107+
if (!query) {
108+
return [
109+
{
110+
onSelect({ suggestion }) {
111+
saveRecentSearch(suggestion);
112+
onClose();
113+
},
114+
getSuggestionUrl({ suggestion }) {
115+
return suggestion.url;
116+
},
117+
getSuggestions() {
118+
return recentSearches.getAll();
119+
},
120+
},
121+
{
122+
onSelect({ suggestion }) {
123+
saveRecentSearch(suggestion);
124+
onClose();
125+
},
126+
getSuggestionUrl({ suggestion }) {
127+
return suggestion.url;
128+
},
129+
getSuggestions() {
130+
return favoriteSearches.getAll();
131+
},
132+
},
133+
];
134+
}
135+
107136
return getAlgoliaHits({
108137
searchClient,
109138
queries: [
@@ -174,35 +203,6 @@ export function DocSearch({
174203
});
175204
}
176205

177-
if (!query) {
178-
return [
179-
{
180-
onSelect({ suggestion }) {
181-
saveRecentSearch(suggestion);
182-
onClose();
183-
},
184-
getSuggestionUrl({ suggestion }) {
185-
return suggestion.url;
186-
},
187-
getSuggestions() {
188-
return recentSearches.getAll();
189-
},
190-
},
191-
{
192-
onSelect({ suggestion }) {
193-
saveRecentSearch(suggestion);
194-
onClose();
195-
},
196-
getSuggestionUrl({ suggestion }) {
197-
return suggestion.url;
198-
},
199-
getSuggestions() {
200-
return favoriteSearches.getAll();
201-
},
202-
},
203-
];
204-
}
205-
206206
return Object.values<DocSearchHit[]>(sources).map(items => {
207207
return {
208208
onSelect({ suggestion }) {

0 commit comments

Comments
 (0)