fix(geocode): replace AbortSignal.timeout with AbortController for compatibility

- AbortSignal.timeout not supported on all mobile browsers
- Manual AbortController + setTimeout works everywhere
- Fixes location not showing on dashboard and history first point

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-10 03:25:14 -04:00
co-authored by Copilot
parent 11f07dec38
commit c5982e905f
2 changed files with 10 additions and 6 deletions
+5 -3
View File
@@ -199,10 +199,12 @@ _recenterBtn.addEventListener('click', function () {
function reverseGeocode(lat, lon) {
const el = document.getElementById('gps-location-name');
const fallback = `${lat.toFixed(5)}, ${lon.toFixed(5)}`;
fetch(`/api/geocode?lat=${lat}&lon=${lon}`, { signal: AbortSignal.timeout(6000) })
.then(r => r.ok ? r.json() : null)
const ctrl = new AbortController();
const t = setTimeout(() => ctrl.abort(), 6000);
fetch(`/api/geocode?lat=${lat}&lon=${lon}`, { signal: ctrl.signal })
.then(r => { clearTimeout(t); return r.ok ? r.json() : null; })
.then(data => { el.textContent = (data && data.label) ? data.label : fallback; })
.catch(() => { el.textContent = fallback; });
.catch(() => { clearTimeout(t); el.textContent = fallback; });
}
function _movedEnough(lat, lon) {