-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "Near Me" queries #57
Conversation
- added `executeSearchWithUserLocation` function J=SLAP-1706 TEST=manual - set location to washington DC in when vertical page is loaded, click update my location, and see that the label is updated to my device's location. - set default search query to 'engineers near me' and see that user location is set based on location near my device.
@@ -17,7 +19,14 @@ export default function UniversalSearchPage(props: { universalResultsConfig: Uni | |||
vertical: {} | |||
}) | |||
answersActions.setVerticalKey(''); | |||
answersActions.executeUniversalQuery(); | |||
const executeQuery = async () => { | |||
let searchIntents: SearchIntent[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic looks correct, however I find it a little difficult to follow since it requires me to go back and forth between the search-operations class to understand it. Would something like this work:
if ( state.location.userLocation ) {
executeSearch()
} else {
const intents = getSearchIntents()
updateLocationIfNeeded(intents)
executeSearch()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in both condition, it would still call executeSearch
so I think it's better to just extract it out of the if/else and call it once. But I updated the function to be updateLocationIfNeeded
as suggested, hopefully that's easier to understand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
Add support for 'Near me' queries in search bar
search-operations
file that includes util functions for executing search, getting search intents, and user locationVerticalSearchPage
andUniversalSearchPage
fetch searchIntents from autocomplete search, in the case of a default initial search with near me intent, get and update user's location if there is a near me intent, and execute query.Note: there's a noticeable wait time when navigator.geolocation is used. and there isn't any indication that the results maybe in loading state. Should consider exposing a setLoadingStatus in answersHeadless, so it can be use when executeSearchWithUserLocation is triggered.
J=SLAP-1706
TEST=manual
LocationBias
component, and see that the label is updated to my device's location.