Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen Truong committed Nov 22, 2021
1 parent 7198c9f commit 858f785
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sample-app/src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ export default function SearchBar({
* Allow a query search to wait on the response to the autocomplete request right
* before the search execution in order to retrieve the search intents
*/
const responseToLatestRequestRef = useRef<Promise<AutocompleteResponse|undefined>>();
const autocompletePromiseRef = useRef<Promise<AutocompleteResponse|undefined>>();
const [ autocompleteResponse, executeAutocomplete] = useAutocomplete(isVertical);

async function executeQuery () {
let intents: SearchIntent[] = [];
if (!answersActions.state.location.userLocation) {
const responseToLatestRequest = await responseToLatestRequestRef.current;
intents = responseToLatestRequest?.inputIntents || [];
const autocompleteResponseBeforeSearch = await autocompletePromiseRef.current;
intents = autocompleteResponseBeforeSearch?.inputIntents || [];
}
executeSearchWithIntents(answersActions, isVertical, intents, geolocationOptions);
}
Expand Down Expand Up @@ -79,7 +79,7 @@ export default function SearchBar({
answersActions.setQuery(value);
}}
updateDropdown={() => {
responseToLatestRequestRef.current = executeAutocomplete();
autocompletePromiseRef.current = executeAutocomplete();
}}
renderButtons={renderSearchButton}
cssClasses={{
Expand Down

0 comments on commit 858f785

Please sign in to comment.