Fix SDR device type not synced on page refresh

Initialize currentDeviceList from server-provided deviceList on page load
and auto-select the correct hardware type dropdown value. Previously the
device list was empty until "Refresh Devices" was clicked, causing the
hardware type dropdown to show incorrect values.

Fixes #99

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-02-02 21:26:23 +00:00
parent df634dc741
commit 334073089f

View File

@@ -2418,6 +2418,19 @@
// Load bias-T setting from localStorage
loadBiasTSetting();
// Initialize device list from server-provided data
// This ensures currentDeviceList is populated on page load (fixes #99)
if (typeof deviceList !== 'undefined' && deviceList.length > 0) {
currentDeviceList = deviceList;
const firstType = deviceList[0].sdr_type || 'rtlsdr';
const sdrTypeSelect = document.getElementById('sdrTypeSelect');
if (sdrTypeSelect) {
sdrTypeSelect.value = firstType;
}
// Defer onSDRTypeChanged to ensure DOM is ready
setTimeout(onSDRTypeChanged, 0);
}
// Initialize observer location input fields from saved location
const obsLatInput = document.getElementById('obsLat');
const obsLonInput = document.getElementById('obsLon');