From 7683a925df5d46a38b05bffacbb8b714660d0d44 Mon Sep 17 00:00:00 2001 From: Smittix Date: Fri, 27 Feb 2026 12:18:54 +0000 Subject: [PATCH] fix: update radiosonde stop UI immediately on click The stop button appeared unresponsive because UI updates waited for the server response. If the fetch hung or errored, the user saw nothing. Now the UI updates immediately (matching the pager stop pattern) and the server request happens in the background. Co-Authored-By: Claude Opus 4.6 --- templates/partials/modes/radiosonde.html | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/templates/partials/modes/radiosonde.html b/templates/partials/modes/radiosonde.html index 2b3a9dc..0ee3d70 100644 --- a/templates/partials/modes/radiosonde.html +++ b/templates/partials/modes/radiosonde.html @@ -166,19 +166,23 @@ } function stopRadiosondeTracking() { + // Update UI immediately so the user sees feedback + document.getElementById('startRadiosondeBtn').style.display = 'block'; + document.getElementById('stopRadiosondeBtn').style.display = 'none'; + document.getElementById('radiosondeStatusText').textContent = 'Stopping...'; + document.getElementById('radiosondeStatusText').style.color = 'var(--accent-yellow)'; + + if (radiosondeEventSource) { + radiosondeEventSource.close(); + radiosondeEventSource = null; + } + fetch('/radiosonde/stop', { method: 'POST' }) .then(r => r.json()) .then(() => { - document.getElementById('startRadiosondeBtn').style.display = 'block'; - document.getElementById('stopRadiosondeBtn').style.display = 'none'; document.getElementById('radiosondeStatusText').textContent = 'Standby'; - document.getElementById('radiosondeStatusText').style.color = 'var(--accent-yellow)'; document.getElementById('radiosondeBalloonCount').textContent = '0'; document.getElementById('radiosondeLastUpdate').textContent = '\u2014'; - if (radiosondeEventSource) { - radiosondeEventSource.close(); - radiosondeEventSource = null; - } radiosondeBalloons = {}; // Clear map markers if (typeof radiosondeMap !== 'undefined' && radiosondeMap) { @@ -187,6 +191,9 @@ radiosondeTracks.forEach(t => radiosondeMap.removeLayer(t)); radiosondeTracks.clear(); } + }) + .catch(() => { + document.getElementById('radiosondeStatusText').textContent = 'Standby'; }); }