fix: who's-on-air freq/appearance lag — prompt publish on activity + 5s widget poll
publishLiveStatus only ran on QSO log or the 15s heartbeat, and the widget polled every 15s, so an operator's band/freq (and their appearance) could trail by up to a minute. Now ReportLiveActivity debounce-publishes ~1.5s after a freq/band/mode change, and the widget polls every 5s (and 1.5s after qso:logged).
This commit is contained in:
+15
-2
@@ -159,10 +159,23 @@ func (a *App) liveStatusOperator() (op, station string) {
|
||||
// ReportLiveActivity is called by the UI with the current entry-strip freq/band/
|
||||
// mode, used as a fallback for live status when the CAT isn't connected.
|
||||
func (a *App) ReportLiveActivity(freqHz int64, band, mode string) {
|
||||
nb := strings.ToUpper(strings.TrimSpace(band))
|
||||
nm := strings.ToUpper(strings.TrimSpace(mode))
|
||||
a.liveActMu.Lock()
|
||||
changed := a.liveFreqHz != freqHz || a.liveBand != nb || a.liveMode != nm
|
||||
a.liveFreqHz = freqHz
|
||||
a.liveBand = strings.ToUpper(strings.TrimSpace(band))
|
||||
a.liveMode = strings.ToUpper(strings.TrimSpace(mode))
|
||||
a.liveBand = nb
|
||||
a.liveMode = nm
|
||||
// Push a fresh row PROMPTLY when the operator's freq/band/mode changes, instead
|
||||
// of waiting for the next 15 s heartbeat — otherwise "who's on air" showed a
|
||||
// stale band and took up to a minute to catch up. Debounced so spinning the VFO
|
||||
// doesn't hammer the shared MySQL.
|
||||
if changed {
|
||||
if a.livePublishTimer != nil {
|
||||
a.livePublishTimer.Stop()
|
||||
}
|
||||
a.livePublishTimer = time.AfterFunc(1500*time.Millisecond, func() { a.publishLiveStatus() })
|
||||
}
|
||||
a.liveActMu.Unlock()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user