fix(bandopen): honour the operator's band selection
The chips in Settings only ever shaped the PSK Reporter SUBSCRIPTION. Neither feed path checked them: both asked bandopen.Watched, which says which bands the detector is capable of and knows nothing about the selection. So the cluster path announced every watched band regardless, and widening the subscription to "+" for grid chasing let PSK Reporter do the same — a station with only 6 m ticked got 10 m and 2 m badges. The selection is now cached beside the on/off flag and checked on both paths, and unticking a band puts its badge out: badges fade on a timer fed by spots the detector no longer looks at, so it would otherwise stay lit until a restart.
This commit is contained in:
+45
-3
@@ -28,8 +28,15 @@ type bandOpenState struct {
|
||||
// settings query per spot is exactly what the rest of this file avoids.
|
||||
// startBandOpenFeed owns it — it runs at startup and again on every save, so
|
||||
// the switch takes effect without a restart.
|
||||
on atomic.Bool
|
||||
mu sync.Mutex
|
||||
on atomic.Bool
|
||||
// bands is the operator's SELECTED set, held as map[string]bool.
|
||||
//
|
||||
// bandopen.Watched only says which bands the detector is capable of; it
|
||||
// knows nothing about the chips in Settings. Nothing checked the selection
|
||||
// on either feed path, so unticking 10 m and 2 m changed the subscription and
|
||||
// left the cluster path announcing them anyway.
|
||||
bands atomic.Value
|
||||
mu sync.Mutex
|
||||
det *bandopen.Detector
|
||||
last []bandopen.Opening // most recent first, for the UI
|
||||
// live holds the announced openings that are still going, keyed by band, and
|
||||
@@ -60,7 +67,7 @@ func (a *App) detectBandOpening(s cluster.Spot) {
|
||||
// itself ran on every ordinary cluster spot. So an operator who had never
|
||||
// enabled the watch still got opening banners, from a feature they had
|
||||
// deliberately left off.
|
||||
if !a.bandOpen.on.Load() {
|
||||
if !a.bandOpen.on.Load() || !a.bandOpenWanted(s.Band) {
|
||||
return
|
||||
}
|
||||
// No operator grid = no distance and no bearing on the spot, and the whole
|
||||
@@ -140,6 +147,41 @@ func (a *App) GetLiveOpenings() []bandopen.Opening {
|
||||
return out
|
||||
}
|
||||
|
||||
// bandOpenWanted reports whether the operator has this band ticked. Falls back
|
||||
// to the detector's own set until a selection has been stored, so a band is
|
||||
// never silently dropped before the settings have been read.
|
||||
func (a *App) bandOpenWanted(band string) bool {
|
||||
if !bandopen.Watched(band) {
|
||||
return false
|
||||
}
|
||||
sel, ok := a.bandOpen.bands.Load().(map[string]bool)
|
||||
if !ok || len(sel) == 0 {
|
||||
return true
|
||||
}
|
||||
return sel[strings.ToLower(strings.TrimSpace(band))]
|
||||
}
|
||||
|
||||
// setBandOpenBands records the selection and puts out badges for bands that
|
||||
// have just been unticked — they fade on a timer fed by spots the detector no
|
||||
// longer looks at, so they would otherwise stay lit until the next restart.
|
||||
func (a *App) setBandOpenBands(bands []string) {
|
||||
sel := make(map[string]bool, len(bands))
|
||||
for _, b := range bands {
|
||||
sel[strings.ToLower(strings.TrimSpace(b))] = true
|
||||
}
|
||||
a.bandOpen.bands.Store(sel)
|
||||
|
||||
a.bandOpen.mu.Lock()
|
||||
defer a.bandOpen.mu.Unlock()
|
||||
for b := range a.bandOpen.live {
|
||||
if len(sel) > 0 && !sel[b] {
|
||||
delete(a.bandOpen.live, b)
|
||||
delete(a.bandOpen.aliveUntil, b)
|
||||
applog.Printf("bandopen: %s is no longer watched — badge cleared", strings.ToUpper(b))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clearBandOpenings puts out every lit badge and forgets the detector's window.
|
||||
// Called when the watch is switched off: the badges fade on a timer fed by
|
||||
// spots the detector no longer looks at, so without this they would stay up
|
||||
|
||||
Reference in New Issue
Block a user