Skip to content

Commit

Permalink
CM-1152: Add maximumAge 10 minutes to getCurrentPosition (#1139)
Browse files Browse the repository at this point in the history
  • Loading branch information
molund authored Dec 13, 2023
1 parent ad8ef79 commit 03794cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/gatsby/src/components/search/cityNameSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const CityNameSearch = ({
}
const getLocation = () => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition, showError)
navigator.geolocation.getCurrentPosition(showPosition, showError, { maximumAge: 600000 })
} else {
console.log("Geolocation is not supported by your browser")
}
Expand Down
14 changes: 8 additions & 6 deletions src/gatsby/src/pages/find-a-park.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ export default function FindAPark({ location, data }) {
setAcquiringGeolocation(false)
setQsLocation(undefined)
setSelectedCity([])
})
}, { maximumAge: 600000 })
} else {
setAcquiringGeolocation(false);
console.log("Geolocation is not supported by your browser")
Expand Down Expand Up @@ -655,13 +655,14 @@ export default function FindAPark({ location, data }) {

useEffect(() => {
if (selectedCity.length > 0) {
if (selectedCity[0].latitude !== 0 && selectedCity[0].longitude !== 0) {
setAcquiringGeolocation(false)
}
if (selectedCity[0].latitude === 0 || selectedCity[0].longitude === 0) {
setAcquiringGeolocation(true)
} else {
setAcquiringGeolocation(false)
}
if (qsLocation !== selectedCity[0].strapi_id.toString()) {
setQsLocation(selectedCity[0].strapi_id.toString())
}
setQsLocation(selectedCity[0].strapi_id.toString())
} else {
setAcquiringGeolocation(false)
}
Expand Down Expand Up @@ -798,7 +799,8 @@ export default function FindAPark({ location, data }) {
<div className="search-results-list">
{/* park results text */}
<p className="result-count-text">
{(isLoading || acquiringGeolocation) && <>Searching...</>}
{acquiringGeolocation && <>Getting location...</>}
{(isLoading && !acquiringGeolocation) && <>Searching...</>}
{(!isLoading && !acquiringGeolocation) && (
<>
<b>
Expand Down

0 comments on commit 03794cb

Please sign in to comment.