[fix](trx-frontend-http): stop fetching /bookmarks on every SSE state update

applyRigList() was called on every SSE state update (since `remotes`
is always present in the payload), and it unconditionally called
bmFetch() which fires 2x GET /bookmarks (list + overlay). At the
default poll rate this generated ~20 bookmark fetches/second — visible
as constant GET /bookmarks traffic on each spectrum render cycle.

Now track the previous rig list + active rig as a key and only
re-fetch bookmarks (and re-init scheduler/background-decode) when
the rig list actually changes.

https://claude.ai/code/session_017g7VNMb6CChaiWrfzVBhbR
Signed-off-by: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-03-28 17:33:47 +00:00
committed by Stan Grams
parent afaf19d2b4
commit 842ee6f076
@@ -1027,7 +1027,11 @@ function updateRigSubtitle(activeRigId) {
function applyRigList(activeRigId, rigIds, displayNames) {
if (!Array.isArray(rigIds)) return;
lastRigIds = rigIds.filter((id) => typeof id === "string" && id.length > 0);
const nextIds = rigIds.filter((id) => typeof id === "string" && id.length > 0);
// Detect whether the rig list or active rig actually changed so we can
// skip expensive bookmark re-fetches on every SSE state update.
const prevKey = lastRigIds.join("\0") + "|" + (lastActiveRigId || "");
lastRigIds = nextIds;
if (displayNames && typeof displayNames === "object") {
lastRigDisplayNames = { ...displayNames };
}
@@ -1045,13 +1049,17 @@ function applyRigList(activeRigId, rigIds, displayNames) {
const aboutActive = document.getElementById("about-active-rig");
if (aboutActive) aboutActive.textContent = lastActiveRigId;
}
const nextKey = lastRigIds.join("\0") + "|" + (lastActiveRigId || "");
const rigListChanged = prevKey !== nextKey;
const disableSwitch = lastRigIds.length === 0 || !authRole || authRole === "rx";
populateRigPicker(headerRigSwitchSelect, lastRigIds, lastActiveRigId, disableSwitch);
updateRigSubtitle(lastActiveRigId);
if (rigListChanged) {
if (typeof setSchedulerRig === "function") setSchedulerRig(lastActiveRigId);
if (typeof setBackgroundDecodeRig === "function") setBackgroundDecodeRig(lastActiveRigId);
if (typeof bmPopulateScopePicker === "function") bmPopulateScopePicker();
if (typeof bmFetch === "function") bmFetch(document.getElementById("bm-category-filter")?.value || "");
}
updateMapRigFilter();
}