This commit is contained in:
2026-06-07 17:45:08 +02:00
parent 7d80d26bbd
commit 3dd9620cca
7 changed files with 133 additions and 77 deletions
+41 -14
View File
@@ -27,7 +27,7 @@ import {
GetWinkeyerSettings, SaveWinkeyerSettings, ListSerialPorts, GetWinkeyerStatus,
WinkeyerConnect, WinkeyerDisconnect, WinkeyerSend, WinkeyerStop, WinkeyerSetSpeed, WinkeyerBackspace,
GetDVKMessages, GetDVKStatus, DVKPlay, DVKStop,
QSOAudioBegin, QSOAudioCancel,
QSOAudioBegin, QSOAudioCancel, QSOAudioRestart,
GetAwardDefs,
} from '../wailsjs/go/main/App';
import { Combobox } from '@/components/ui/combobox';
@@ -654,6 +654,11 @@ export default function App() {
// tell whether an incoming DX call actually changed anything.
const callsignValRef = useRef('');
useEffect(() => { callsignValRef.current = callsign; }, [callsign]);
// True while the operator is typing in the Call field. A call change that
// arrives while it's NOT focused is programmatic (clicked spot / external app
// via UDP) → we (re)start the recording immediately; typed changes wait for
// blur so we don't restart on every keystroke.
const callFocusedRef = useRef(false);
// When the entered callsign turns out to be worked-before, jump to the
// Worked-before tab so the history is front-and-centre. Only once per call,
@@ -817,6 +822,16 @@ export default function App() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
// applyModeFromSpot updates the mode AND its RST default for a fresh target
// (clicked spot / rig-driven mode change). Unlike a manual mode tweak, this
// is a new contact, so we clear the "user edited RST" flag first — otherwise
// a 599 left from a CW QSO would stick when jumping to an SSB spot.
function applyModeFromSpot(m: string) {
if (!m) return;
setMode(m);
rstUserEditedRef.current = false;
applyModePreset(m);
}
function applyModePreset(m: string) {
if (rstUserEditedRef.current) return;
// Prefer the user's configured preset RST; otherwise fall back to the mode
@@ -876,12 +891,15 @@ export default function App() {
// 3. Else trust CAT (SSB, CW, AM, FM…).
if (!lk.mode) {
const inferred = s.freq_hz ? inferDigitalMode(s.freq_hz) : '';
if (inferred) {
setMode(inferred);
} else if (s.mode === 'DATA') {
setMode(digitalDefaultRef.current || 'FT8');
} else if (s.mode) {
setMode(s.mode);
let nextMode = '';
if (inferred) nextMode = inferred;
else if (s.mode === 'DATA') nextMode = digitalDefaultRef.current || 'FT8';
else if (s.mode) nextMode = s.mode;
if (nextMode) {
setMode(nextMode);
// Flip the RST default (599↔59) when the rig changes mode. Respects a
// user-edited RST (applyModePreset early-returns when edited).
applyModePreset(nextMode);
}
}
});
@@ -1394,6 +1412,13 @@ export default function App() {
}
setCallsign(v);
scheduleLookup(v);
// Programmatic call change (clicked spot, or external app via UDP) for a new
// non-empty target → (re)start the recording now, even if one was already
// running for the previous contact. Typed changes (field focused) wait for
// blur so we don't restart per keystroke.
if (v.trim() !== '' && !callFocusedRef.current) {
QSOAudioRestart().then(setRecording).catch(() => {});
}
}
function markEdited(field: string) { userEditedRef.current.add(field); }
@@ -1615,10 +1640,11 @@ export default function App() {
ref={callsignRef}
className="font-mono text-base font-bold tracking-wider uppercase h-9 bg-muted/40 focus:bg-card"
value={callsign}
onFocus={() => { callFocusedRef.current = true; }}
onChange={(e) => onCallsignInput(e.target.value)}
// Start the QSO recording when leaving the callsign field (the pre-roll
// covers the seconds before). No-op when the recorder is off.
onBlur={() => { if (callsign.trim()) QSOAudioBegin().then(setRecording).catch(() => {}); }}
onBlur={() => { callFocusedRef.current = false; if (callsign.trim()) QSOAudioBegin().then(setRecording).catch(() => {}); }}
/>
</div>
</div>
@@ -2585,17 +2611,18 @@ export default function App() {
} else {
setFreqMhz((s.freq_hz / 1_000_000).toFixed(5));
if (s.band) setBand(s.band);
if (m) setMode(m);
}
// Set mode + flip the RST default (599↔59) for the new
// target — a plain setMode skipped the RST preset.
if (m) applyModeFromSpot(m);
onCallsignInput(s.dx_call);
// A POTA spot carries the park ref — pre-fill the POTA
// award reference (like the State→RAC auto-match) so it's
// logged without re-typing. n-fer refs (comma-separated)
// become one POTA@ entry each.
applySpotPOTA((s as any).pota_ref);
// Clicking a spot fills the call programmatically (no blur
// on the call field), so start the QSO recording here too.
if (s.dx_call.trim()) QSOAudioBegin().then(setRecording).catch(() => {});
// (recording (re)starts inside onCallsignInput — the call
// changed programmatically with the field unfocused.)
}}
/>
);
@@ -2808,11 +2835,11 @@ export default function App() {
} else {
setFreqMhz((s.freq_hz / 1_000_000).toFixed(5));
if (s.band) setBand(s.band);
if (m) setMode(m);
}
if (m) applyModeFromSpot(m);
onCallsignInput(s.dx_call);
applySpotPOTA((s as any).pota_ref);
if (s.dx_call.trim()) QSOAudioBegin().then(setRecording).catch(() => {});
// (recording (re)starts inside onCallsignInput — programmatic call change)
}}
onClose={() => setShowBandMap(false)}
/>