fix: Socket gps_location now passes lat/lon to renderGpsStatus, preventing overwrite with blanks

This commit is contained in:
Mathieu Moran
2026-08-11 16:37:01 -04:00
parent e8156bc39a
commit a4a92cc69b
+9 -9
View File
@@ -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);
}