Harden ADS-B dashboard bootstrap

This commit is contained in:
James Smith
2026-03-19 08:35:43 +00:00
parent 54ad3b9362
commit 4410aa2433

View File

@@ -1735,27 +1735,54 @@ ACARS: ${r.statistics.acarsMessages} messages`;
if (delayedAircraftDbTimer) { clearTimeout(delayedAircraftDbTimer); delayedAircraftDbTimer = null; } if (delayedAircraftDbTimer) { clearTimeout(delayedAircraftDbTimer); delayedAircraftDbTimer = null; }
}); });
function ensureAdsbMapBootstrapped() {
if (radarMap) return;
try {
initMap();
} catch (e) {
console.error('ADS-B map bootstrap failed:', e);
}
}
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
// Initialize observer location input fields from saved location // Bring the map up first so a later startup error cannot leave the
const obsLatInput = document.getElementById('obsLat'); // dashboard in a half-rendered "shell only" state.
const obsLonInput = document.getElementById('obsLon'); ensureAdsbMapBootstrapped();
if (obsLatInput) obsLatInput.value = observerLocation.lat.toFixed(4);
if (obsLonInput) obsLonInput.value = observerLocation.lon.toFixed(4);
// Initialize detection sound toggle from localStorage try {
const detectionToggle = document.getElementById('detectionSoundToggle'); // Initialize observer location input fields from saved location
if (detectionToggle) detectionToggle.checked = detectionSoundEnabled; const obsLatInput = document.getElementById('obsLat');
const obsLonInput = document.getElementById('obsLon');
if (obsLatInput) obsLatInput.value = observerLocation.lat.toFixed(4);
if (obsLonInput) obsLonInput.value = observerLocation.lon.toFixed(4);
// Load Bias-T setting from localStorage // Initialize detection sound toggle from localStorage
loadAdsbBiasTSetting(); const detectionToggle = document.getElementById('detectionSoundToggle');
if (detectionToggle) detectionToggle.checked = detectionSoundEnabled;
} catch (e) {
console.error('ADS-B UI bootstrap warning:', e);
}
try {
loadAdsbBiasTSetting();
} catch (e) {
console.error('ADS-B Bias-T bootstrap warning:', e);
}
initMap();
initDeviceSelectors() initDeviceSelectors()
.then((devices) => checkAdsbTools(devices)) .then((devices) => checkAdsbTools(devices))
.catch(() => checkAdsbTools([])); .catch((e) => {
updateClock(); console.error('ADS-B device selector bootstrap warning:', e);
clockInterval = setInterval(updateClock, 1000); checkAdsbTools([]);
cleanupInterval = setInterval(cleanupOldAircraft, 10000); });
try {
updateClock();
clockInterval = setInterval(updateClock, 1000);
cleanupInterval = setInterval(cleanupOldAircraft, 10000);
} catch (e) {
console.error('ADS-B timer bootstrap warning:', e);
}
// Defer nonessential startup probes so the page can paint and // Defer nonessential startup probes so the page can paint and
// return navigation remains snappy if the user leaves quickly. // return navigation remains snappy if the user leaves quickly.
@@ -1774,8 +1801,16 @@ ACARS: ${r.statistics.acarsMessages} messages`;
autoConnectGps(); autoConnectGps();
}, 2500); }, 2500);
// Sync tracking state if ADS-B already running syncTrackingStatus().catch((e) => {
syncTrackingStatus(); console.error('ADS-B tracking status bootstrap warning:', e);
});
});
window.addEventListener('load', () => {
if (!radarMap) {
console.warn('ADS-B map was not initialized during DOMContentLoaded, retrying on window load');
ensureAdsbMapBootstrapped();
}
}); });
// Track which device is being used for ADS-B tracking // Track which device is being used for ADS-B tracking