feat: merge home/search pages, add filters/sorting/infinite scroll, nearby sort with IP fallback
This commit is contained in:
@@ -603,9 +603,9 @@ class SearchBox extends HTMLElement {
|
||||
|
||||
const cancelled = !this.dispatchEvent(event)
|
||||
|
||||
// Navigate to search page unless event was cancelled
|
||||
// Navigate to home page with params unless event was cancelled
|
||||
if (!cancelled && !this.hasAttribute('no-navigate')) {
|
||||
const url = '#/search' + (params.toString() ? '?' + params.toString() : '')
|
||||
const url = '#/' + (params.toString() ? '?' + params.toString() : '')
|
||||
window.location.hash = url
|
||||
}
|
||||
}
|
||||
@@ -625,6 +625,7 @@ class SearchBox extends HTMLElement {
|
||||
this.currentLng = position.coords.longitude
|
||||
this.geoLoading = false
|
||||
this.updateGeoButton()
|
||||
this.emitFilterChange()
|
||||
},
|
||||
(error) => {
|
||||
console.warn('Geolocation error:', error)
|
||||
@@ -635,10 +636,27 @@ class SearchBox extends HTMLElement {
|
||||
}
|
||||
|
||||
handleGeoError() {
|
||||
// Keep useCurrentLocation = true, just stop loading indicator
|
||||
// User can still search by current location (backend will handle it)
|
||||
// Try IP-based geolocation as fallback
|
||||
this.fetchIpLocation()
|
||||
}
|
||||
|
||||
async fetchIpLocation() {
|
||||
try {
|
||||
const response = await fetch('https://ipapi.co/json/')
|
||||
if (response.ok) {
|
||||
const data = await response.json()
|
||||
if (data.latitude && data.longitude) {
|
||||
this.currentLat = data.latitude
|
||||
this.currentLng = data.longitude
|
||||
console.log('IP-based location:', data.city, data.country_code)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('IP geolocation failed:', e)
|
||||
}
|
||||
this.geoLoading = false
|
||||
this.updateGeoButton()
|
||||
this.emitFilterChange()
|
||||
}
|
||||
|
||||
updateGeoButton() {
|
||||
|
||||
Reference in New Issue
Block a user