feat(cluster): configurable spot lifetime

Spots were bounded by COUNT alone, so on a quiet band a two-hour-old spot sat
on the band map looking like something to chase. Settings → DX Cluster now
takes a lifetime: presets at 5/10/15/30/60 minutes, or any value up to twelve
hours, and 0 keeps the old behaviour.

Spots are REMOVED from the shared list rather than hidden at render. The
cluster list, every band map and the counts all read that one array, so pruning
it once is what makes the setting mean the same thing in every view — the
lesson already paid for when the band map ignored the cluster's filters. It
also gives the memory back.

A spot whose timestamp will not parse is never dropped: an unreadable stamp is
a reason to distrust the clock, not to throw away the spot.

Swept every 30 seconds — close enough that a 5-minute setting is honoured, and
invisible next to the spot stream. Clamped in the backend as well as the UI.
This commit is contained in:
2026-08-13 10:38:08 +02:00
parent f8fb57210f
commit b2382a6135
7 changed files with 109 additions and 5 deletions
+26 -1
View File
@@ -91,7 +91,7 @@ import { ShutdownProgress } from '@/components/ShutdownProgress';
import { ClusterGrid } from '@/components/ClusterGrid';
import { cleanSpotter, inferSpotMode, spotModeCategory, spotStatusKey } from '@/lib/spot';
import { applySpotDisplay, readSpotDisplayOptions, spotIsWorked, SPOT_DISPLAY_OPTIONS_EXPOSED } from '@/lib/spotDisplay';
import { GetRowColors } from '../wailsjs/go/main/App';
import { GetRowColors, GetSpotTTLMinutes } from '../wailsjs/go/main/App';
import { WorkedBeforeGrid } from '@/components/WorkedBeforeGrid';
import { NetControlPanel } from '@/components/NetControlPanel';
import { ContestPanel, CONTEST_DEFAULT, type ContestSession } from '@/components/ContestPanel';
@@ -1928,6 +1928,31 @@ export default function App() {
// settings dialog closes, which is the only place it changes.
const [rowColors, setRowColors] = useState<any>(null);
useEffect(() => { GetRowColors().then(setRowColors).catch(() => {}); }, [showSettings]);
// Spot lifetime (Settings → DX Cluster). Spots are actually REMOVED rather
// than filtered at render: the cluster list, every band map and the counts all
// read the same array, so pruning it once is what makes the setting mean the
// same thing everywhere — and it gives the memory back.
const [spotTTLMin, setSpotTTLMin] = useState(0);
useEffect(() => { GetSpotTTLMinutes().then(setSpotTTLMin).catch(() => {}); }, [showSettings]);
useEffect(() => {
if (spotTTLMin <= 0) return; // 0 = keep until the count cap pushes them out
const sweep = () => {
const cutoff = Date.now() - spotTTLMin * 60_000;
setSpots((arr) => {
const kept = arr.filter((sp) => {
const t = Date.parse((sp as any).received_at ?? '');
return isNaN(t) || t >= cutoff; // an unparseable stamp is never a reason to drop a spot
});
return kept.length === arr.length ? arr : kept;
});
};
sweep();
// Half a minute: fine enough that a 5-minute setting is honoured closely,
// coarse enough to be invisible next to the spot stream itself.
const id = window.setInterval(sweep, 30_000);
return () => window.clearInterval(id);
}, [spotTTLMin]);
const qsosWithAwards = useMemo(
() => (qsos as any[]).map((q) => ({ ...q, award_refs: parseAwardRefs(q.award_refs) })),
[qsos],