fix(bandopen): stop subscribing to a band nobody watches, and drop the toast

A saved band selection outlives the code that made it. 12 m was removed from the
watched set, but every operator who had already enabled the watch kept
subscribing to it — paying for a firehose whose messages the detector then threw
away. The stored list is filtered against the offered one now.

The badge appeared on the next poll rather than on the event, up to twenty
seconds after the announcement, so the two read as unrelated things that happened
to mention the same band. It appears immediately.

And the toast is gone. It said the same thing as the badge and vanished after
five seconds — an operator who was tuning when it passed had no way back to it,
which is precisely what the badge was built to fix. Keeping both announced an
opening twice and still lost it once.
This commit is contained in:
2026-08-11 18:11:09 +02:00
parent 298c2fde44
commit 9fd801ea69
4 changed files with 33 additions and 9 deletions
+19
View File
@@ -51,12 +51,31 @@ func (a *App) GetBandOpenSettings() BandOpenSettings {
Bands: splitCSV(a.settingOr(keyBandOpenBands, "")),
Available: pskr.Bands,
}
// Keep only bands that are still offered. A saved selection outlives the code
// that made it: 12 m was dropped from the watched set, but every operator who
// had already enabled the watch kept subscribing to it — paying for a firehose
// whose messages the detector then threw away.
s.Bands = keepKnownBands(s.Bands)
if len(s.Bands) == 0 {
s.Bands = append(s.Bands, pskr.Bands...)
}
return s
}
func keepKnownBands(want []string) []string {
ok := make(map[string]bool, len(pskr.Bands))
for _, b := range pskr.Bands {
ok[b] = true
}
out := make([]string, 0, len(want))
for _, b := range want {
if ok[strings.ToLower(strings.TrimSpace(b))] {
out = append(out, b)
}
}
return out
}
func (a *App) SaveBandOpenSettings(s BandOpenSettings) error {
a.setSetting(keyBandOpenEnabled, map[bool]string{true: "1", false: "0"}[s.Enabled])
a.setSetting(keyBandOpenBands, strings.Join(s.Bands, ","))