mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
This commit is contained in:
@@ -286,38 +286,15 @@ function getCATTimings() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle CAT frequency update with adaptive debounce
|
||||
* Uses getCATTimings() to apply appropriate delays for WebSocket (fast) vs Polling (slow)
|
||||
* Returns true if frequency should be updated, false if blocked by debounce
|
||||
* Also handles frequency confirmation and cache invalidation
|
||||
* Handle CAT frequency update
|
||||
* Handles frequency confirmation and cache invalidation
|
||||
* @param {number} radioFrequency - Frequency from CAT in Hz
|
||||
* @param {Function} updateCallback - Function to call if update should proceed
|
||||
* @returns {boolean} - True if update was allowed, false if blocked
|
||||
* @param {Function} updateCallback - Function to call to update UI
|
||||
* @returns {boolean} - True if update was processed
|
||||
*/
|
||||
function handleCATFrequencyUpdate(radioFrequency, updateCallback) {
|
||||
// Get adaptive timing based on connection type (WebSocket vs Polling)
|
||||
var timings = getCATTimings();
|
||||
var now = Date.now();
|
||||
|
||||
// Check if we're in a debounce period
|
||||
if (typeof window.catFrequencyDebounce !== 'undefined' && window.catFrequencyDebounce) {
|
||||
var timeSinceLastUpdate = now - (window.catFrequencyDebounce.lastUpdate || 0);
|
||||
|
||||
// If we're within the commit delay window, skip this update
|
||||
if (timeSinceLastUpdate < timings.commitDelay) {
|
||||
DX_WATERFALL_UTILS.log.debug('[DX Waterfall] CAT DEBOUNCE: Skipping update (within ' + timings.commitDelay + 'ms window, ' + timeSinceLastUpdate + 'ms since last)');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize debounce tracking if needed
|
||||
if (typeof window.catFrequencyDebounce === 'undefined') {
|
||||
window.catFrequencyDebounce = { lastUpdate: 0 };
|
||||
}
|
||||
|
||||
// Update debounce timestamp
|
||||
window.catFrequencyDebounce.lastUpdate = now;
|
||||
|
||||
// Check if frequency actually changed BEFORE updating UI
|
||||
var frequencyChanged = false;
|
||||
var isInitialLoad = false;
|
||||
@@ -414,13 +391,6 @@ function handleCATFrequencyUpdate(radioFrequency, updateCallback) {
|
||||
dxWaterfall.invalidateFrequencyCache();
|
||||
}
|
||||
}
|
||||
|
||||
// Clear any existing auto-populate timer (not used anymore, but clean up if exists)
|
||||
if (window.catFrequencyDebounce.autoPopulateTimer) {
|
||||
clearTimeout(window.catFrequencyDebounce.autoPopulateTimer);
|
||||
window.catFrequencyDebounce.autoPopulateTimer = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -2232,21 +2232,8 @@ $('.mode').on('change', function () {
|
||||
$('#band').on('change', function () {
|
||||
const selectedBand = $(this).val();
|
||||
|
||||
// Skip if this is a programmatic change from CAT/waterfall
|
||||
if (typeof window.programmaticBandChange !== 'undefined' && window.programmaticBandChange) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip resetting frequency if CAT is currently updating
|
||||
if (typeof cat_updating_frequency !== 'undefined' && cat_updating_frequency) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the QSO form when band is manually changed
|
||||
$('#btn_reset').click();
|
||||
|
||||
// Band selector is now display-only - it follows the radio frequency
|
||||
// Manual band changes do NOT update the frequency or tune the radio
|
||||
// Band selector is display-only - it follows the radio frequency
|
||||
// Band changes do NOT clear the form or update the frequency or tune the radio
|
||||
// The radio controls the form, not the other way around
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user