refactor(sat): one satellite list, and out of Hardware
Settings ▸ Lists ▸ Satellites is gone. It was a text box an operator typed their birds into by hand, and it had nothing to do with the satellites the tracker knew: the same station kept two lists of the same satellites and they drifted apart. The SAT_NAME box on the entry form now offers the followed set — or every satellite with a frequency plan when none is followed — merged with whatever that old list still holds, read and never written, because what it holds is somebody's past work. And the satellite section moved out of Hardware, which it never was. Which birds you chase, where your antenna stands and how old your elements are is operating; the rotator inside it is the only hardware there, and one block does not make a section a device.
This commit is contained in:
+42
@@ -11,6 +11,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -590,6 +591,47 @@ func (a *App) GetSatelliteBirds() []SatBird {
|
||||
return out
|
||||
}
|
||||
|
||||
// GetSatelliteNames is the list behind the entry form's SAT_NAME box.
|
||||
//
|
||||
// One list, not two. It used to be a text box in Settings ▸ Lists that an
|
||||
// operator typed their birds into by hand, which then had nothing to do with
|
||||
// the satellites the tracker knew — the same station kept two lists of the same
|
||||
// satellites and they drifted apart. This is the followed set (or every
|
||||
// satellite with a frequency plan, when none is followed), plus anything the
|
||||
// old hand-kept list still holds so nobody's typing is thrown away.
|
||||
//
|
||||
// SAT_NAME is compared character for character by the awards and by LoTW, so
|
||||
// offering the spelling already used beats inventing a new one every pass.
|
||||
func (a *App) GetSatelliteNames() []string {
|
||||
seen := map[string]bool{}
|
||||
var out []string
|
||||
add := func(n string) {
|
||||
n = strings.ToUpper(strings.TrimSpace(n))
|
||||
if n == "" || seen[n] {
|
||||
return
|
||||
}
|
||||
seen[n] = true
|
||||
out = append(out, n)
|
||||
}
|
||||
for _, n := range a.satNames(nil) {
|
||||
add(n)
|
||||
}
|
||||
// The legacy list. Read, never written: the panel that edited it is gone,
|
||||
// and what it holds is somebody's past work.
|
||||
if a.settings != nil {
|
||||
if raw, _ := a.settings.Get(a.ctx, keyListsSatellites); raw != "" {
|
||||
var legacy []string
|
||||
if json.Unmarshal([]byte(raw), &legacy) == nil {
|
||||
for _, n := range legacy {
|
||||
add(n)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sort.Strings(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// satElement finds the elements for a bird, trying its aliases.
|
||||
//
|
||||
// The feed's name and the operator's name for the same satellite are routinely
|
||||
|
||||
Reference in New Issue
Block a user