[fix](trx-frontend-http): populate scheduler rig list after SSE delivers rig data
initScheduler() runs before the first SSE event, so lastRigIds is empty. Now applyRigList() calls reloadSchedulerRigSelect() whenever the rig list updates, and renderSchedulerRigSelect() loads the config for the first rig if currentRigId was previously unset. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -745,6 +745,7 @@ function applyRigList(activeRigId, rigIds, displayNames) {
|
||||
const disableSwitch = lastRigIds.length === 0 || !authRole || authRole === "rx";
|
||||
populateRigPicker(headerRigSwitchSelect, lastRigIds, activeRigId, disableSwitch);
|
||||
updateRigSubtitle(activeRigId);
|
||||
if (typeof reloadSchedulerRigSelect === "function") reloadSchedulerRigSelect();
|
||||
}
|
||||
|
||||
async function refreshRigList() {
|
||||
|
||||
@@ -42,13 +42,8 @@
|
||||
if (!sel) return;
|
||||
// Populate from global rig list exposed by app.js
|
||||
const rigs = (typeof getAvailableRigIds === "function") ? getAvailableRigIds() : [];
|
||||
if (!rigs.length) return; // wait until rig list arrives
|
||||
sel.innerHTML = "";
|
||||
if (!rigs.length) {
|
||||
const opt = document.createElement("option");
|
||||
opt.textContent = "No rigs available";
|
||||
sel.appendChild(opt);
|
||||
return;
|
||||
}
|
||||
rigs.forEach(function (id) {
|
||||
const opt = document.createElement("option");
|
||||
opt.value = id;
|
||||
@@ -56,6 +51,13 @@
|
||||
if (id === currentRigId) opt.selected = true;
|
||||
sel.appendChild(opt);
|
||||
});
|
||||
// If currentRigId was unset, pick the first available rig and load its config.
|
||||
if (!currentRigId || !rigs.includes(currentRigId)) {
|
||||
currentRigId = rigs[0];
|
||||
sel.value = currentRigId;
|
||||
loadScheduler();
|
||||
pollStatus();
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user