fix(rst): a change of mode changes the notation
An operator with a callsign in the field, switching FT8 to SSB, kept "+00" as the report. The edited flag protects a report the operator chose — 57 rather than 59 — and it was holding across a change of mode as well, where it protects nothing: a decibel figure is not a weak SSB report, it is not a report at all. Worse, anything that fills the field from the rig sets that flag too (the S-meter readouts in the rig consoles), so the field could be stuck in the wrong notation for the rest of the QSO. The flag now holds only while the report still belongs to the mode's family. When it does not, the operator's own judgement is carried across where it can be — 57 becomes 579, 599 becomes 59 — and the mode's preset answers where it cannot.
This commit is contained in:
+25
-4
@@ -150,7 +150,7 @@ import { cn } from '@/lib/utils';
|
||||
import { pathBetween, pathBetweenLatLon, gridToLatLon, latLonToGrid } from '@/lib/maidenhead';
|
||||
import { flagURL } from '@/lib/flags';
|
||||
import { LogViewer } from '@/components/LogViewer';
|
||||
import { stepRST } from '@/lib/rst';
|
||||
import { convertRST, rstFitsMode, stepRST } from '@/lib/rst';
|
||||
|
||||
type QSO = QSOForm;
|
||||
type ImportResult = adifModels.ImportResult;
|
||||
@@ -658,6 +658,11 @@ export default function App() {
|
||||
useEffect(() => { rstListsRef.current = rstLists; }, [rstLists]);
|
||||
const [rstSent, setRstSent] = useState('59');
|
||||
const [rstRcvd, setRstRcvd] = useState('59');
|
||||
// Read by applyModePreset, which runs from those same long-lived closures.
|
||||
const rstSentRef = useRef(rstSent);
|
||||
const rstRcvdRef = useRef(rstRcvd);
|
||||
useEffect(() => { rstSentRef.current = rstSent; }, [rstSent]);
|
||||
useEffect(() => { rstRcvdRef.current = rstRcvd; }, [rstRcvd]);
|
||||
const [grid, setGrid] = useState('');
|
||||
const [name, setName] = useState('');
|
||||
const [qth, setQth] = useState('');
|
||||
@@ -3341,15 +3346,31 @@ export default function App() {
|
||||
return m;
|
||||
}
|
||||
function applyModePreset(m: string) {
|
||||
if (rstUserEditedRef.current) return;
|
||||
// AN EDIT IS ABOUT A SIGNAL, NOT ABOUT A NOTATION.
|
||||
//
|
||||
// The edited flag protects a report the operator chose — 57 rather than 59 —
|
||||
// and it used to protect it across a change of mode as well, where it means
|
||||
// nothing: "+00" is not a weak SSB report, it is not a report at all. An
|
||||
// operator with a callsign in the field, switching from FT8 to SSB, was left
|
||||
// with a decibel figure to log, and anything that fills the report from the
|
||||
// rig (the S-meter readouts in the rig consoles) sets that flag too — so the
|
||||
// field could be stuck in the wrong notation for the rest of the QSO.
|
||||
//
|
||||
// So the flag holds only while the report still belongs to the mode. When it
|
||||
// does not, the judgement is carried across where it can be (57 → 579,
|
||||
// 599 → 59) and the preset answers where it cannot.
|
||||
const fits = rstFitsMode(rstSentRef.current, m) && rstFitsMode(rstRcvdRef.current, m);
|
||||
if (rstUserEditedRef.current && fits) return;
|
||||
// Prefer the user's configured preset RST; otherwise fall back to the mode
|
||||
// category default (CW/RTTY/PSK → 599, phone → 59, digital → first option)
|
||||
// so switching SSB→CW flips 59→599 even without a configured preset.
|
||||
// Read through the refs, never the state: see their declaration.
|
||||
const p = modePresetsRef.current.find((x) => x.name === m);
|
||||
const fallback = rstOptions(m, rstListsRef.current)[0] || '';
|
||||
setRstSent(p?.default_rst_sent || fallback);
|
||||
setRstRcvd(p?.default_rst_rcvd || fallback);
|
||||
const keep = (cur: string, preset: string) =>
|
||||
(rstUserEditedRef.current && convertRST(cur, m)) || preset || fallback;
|
||||
setRstSent(keep(rstSentRef.current, p?.default_rst_sent || ''));
|
||||
setRstRcvd(keep(rstRcvdRef.current, p?.default_rst_rcvd || ''));
|
||||
}
|
||||
// Clicking a spot (cluster grid or any band map): tune the rig, set the mode,
|
||||
// fill the call, pre-fill POTA, (re)start the recording. Shared so every spot
|
||||
|
||||
Reference in New Issue
Block a user