From a4a92cc69bb7919aaf0ed4ad299d446250cdd95b Mon Sep 17 00:00:00 2001 From: Mathieu Moran Date: Tue, 11 Aug 2026 16:37:01 -0400 Subject: [PATCH] fix: Socket gps_location now passes lat/lon to renderGpsStatus, preventing overwrite with blanks --- static/js/yaris.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/static/js/yaris.js b/static/js/yaris.js index cfcb327..0475b25 100644 --- a/static/js/yaris.js +++ b/static/js/yaris.js @@ -234,9 +234,11 @@ function renderGpsStatus(status) { label = stale ? 'Stale fix' : 'Live fix'; badgeClass = stale ? 'text-bg-warning' : 'text-bg-success'; detail = formatGpsAge(status.fix_age_seconds); - // Show lat/lon from API response (not just socket events) - if (locX) locX.textContent = status.latitude != null ? Number(status.latitude).toFixed(6) : '—'; - if (locY) locY.textContent = status.longitude != null ? Number(status.longitude).toFixed(6) : '—'; + // Show lat/lon from API response (not just socket events). + // Only update when values are explicitly provided — socket events + // pass lat/lon via innerHTML separately and should not be overwritten. + if (locX && status.latitude != null) locX.textContent = Number(status.latitude).toFixed(6); + if (locY && status.longitude != null) locY.textContent = Number(status.longitude).toFixed(6); } else { label = 'No fix'; badgeClass = 'text-bg-warning'; @@ -262,15 +264,13 @@ async function refreshGpsStatus() { } socket.on('gps_location', function(data) { - const LocationX = document.getElementById('gpsLocationX'); - const LocationY = document.getElementById('gpsLocationY'); - LocationX.innerHTML = data[0]; - LocationY.innerHTML = data[1]; - const lat = parseFloat(data[0]); const lon = parseFloat(data[1]); if (lat != null && lon != null) { - renderGpsStatus({thread_alive: true, has_fix: true, fix_age_seconds: 0}); + renderGpsStatus({ + thread_alive: true, has_fix: true, fix_age_seconds: 0, + latitude: lat, longitude: lon, + }); if (!map.hasLayer(mapTiles)) { mapTiles.addTo(map); }