[fix](trx-frontend-http): instant spectrum overlay on freq/bw changes

Call drawSignalOverlay() synchronously on frequency and bandwidth changes instead of deferring entirely to requestAnimationFrame. Also make bookmark apply fire-and-forget so the click handler returns immediately after optimistic UI updates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-22 07:51:30 +01:00
parent 5821531a93
commit dc2c8b6eb1
2 changed files with 28 additions and 8 deletions
@@ -344,7 +344,9 @@ async function bmApply(bm) {
scheduleSpectrumDraw();
}
// --- Send mode, bandwidth, and frequency to server in parallel ---
// --- Fire-and-forget: send mode, bandwidth, and frequency in parallel ---
// The UI is already updated optimistically above; don't block on the
// network round-trips so the bookmark click feels instant.
const modePromise = (async () => {
const onVirtual = typeof vchanInterceptMode === "function"
&& await vchanInterceptMode(bm.mode);
@@ -370,10 +372,8 @@ async function bmApply(bm) {
await postPath("/set_freq?hz=" + bm.freq_hz);
}
})();
await Promise.all([modePromise, bwPromise, freqPromise]);
// --- Toggle decoders when in DIG mode ---
if (bm.mode === "DIG" && Array.isArray(bm.decoders)) {
// Decoder toggles (DIG mode) — also fire-and-forget.
const decoderPromise = (bm.mode === "DIG" && Array.isArray(bm.decoders)) ? (async () => {
const statusResp = await fetch("/status");
if (statusResp.ok) {
const st = await statusResp.json();
@@ -386,7 +386,12 @@ async function bmApply(bm) {
check("ft8"); check("ft4"); check("ft2"); check("wspr"); check("hf-aprs");
if (toggles.length) await Promise.all(toggles);
}
}
})() : Promise.resolve();
// Don't await — let the network calls settle in the background.
// Errors are logged but don't block the UI.
Promise.all([modePromise, bwPromise, freqPromise, decoderPromise]).catch(
(err) => console.error("Bookmark apply background error:", err)
);
} catch (err) {
console.error("Failed to apply bookmark:", err);
}