feat: added colonns for awards in recent qso
This commit is contained in:
+39
-3
@@ -33,6 +33,7 @@ import {
|
||||
GetAwardDefs,
|
||||
GetUIPref,
|
||||
ReportLiveActivity,
|
||||
AwardRefsForQSOs,
|
||||
} from '../wailsjs/go/main/App';
|
||||
import { Combobox } from '@/components/ui/combobox';
|
||||
import { applyAwardRefs } from '@/lib/awardRefs';
|
||||
@@ -764,6 +765,40 @@ export default function App() {
|
||||
const wbTimerRef = useRef<number | null>(null);
|
||||
const [wb, setWb] = useState<WB | null>(null);
|
||||
const [wbBusy, setWbBusy] = useState(false);
|
||||
|
||||
// Per-award columns for the Recent QSOs / Worked-before grids: load the award
|
||||
// list once, then compute each shown QSO's reference per award and attach it
|
||||
// to the rows (the grids render one hideable column per award).
|
||||
const [awardCols, setAwardCols] = useState<{ code: string; name: string }[]>([]);
|
||||
useEffect(() => {
|
||||
GetAwardDefs().then((defs: any[]) =>
|
||||
setAwardCols(((defs ?? []) as any[]).map((d) => ({ code: d.code, name: d.name })).sort((a, b) => a.code.localeCompare(b.code))),
|
||||
).catch(() => {});
|
||||
}, []);
|
||||
const [qsoAwardRefs, setQsoAwardRefs] = useState<Record<string, Record<string, string>>>({});
|
||||
useEffect(() => {
|
||||
const ids = (qsos as any[]).map((q) => q.id).filter(Boolean);
|
||||
if (ids.length === 0 || awardCols.length === 0) { setQsoAwardRefs({}); return; }
|
||||
let alive = true;
|
||||
AwardRefsForQSOs(ids as any).then((m: any) => { if (alive) setQsoAwardRefs(m ?? {}); }).catch(() => {});
|
||||
return () => { alive = false; };
|
||||
}, [qsos, awardCols.length]);
|
||||
const qsosWithAwards = useMemo(
|
||||
() => (qsos as any[]).map((q) => ({ ...q, award_refs: qsoAwardRefs[String(q.id)] })),
|
||||
[qsos, qsoAwardRefs],
|
||||
);
|
||||
const [wbAwardRefs, setWbAwardRefs] = useState<Record<string, Record<string, string>>>({});
|
||||
useEffect(() => {
|
||||
const ids = ((wb?.entries ?? []) as any[]).map((e) => e.id).filter(Boolean);
|
||||
if (ids.length === 0 || awardCols.length === 0) { setWbAwardRefs({}); return; }
|
||||
let alive = true;
|
||||
AwardRefsForQSOs(ids as any).then((m: any) => { if (alive) setWbAwardRefs(m ?? {}); }).catch(() => {});
|
||||
return () => { alive = false; };
|
||||
}, [wb, awardCols.length]);
|
||||
const wbWithAwards = useMemo(
|
||||
() => (wb ? { ...wb, entries: ((wb.entries ?? []) as any[]).map((e) => ({ ...e, award_refs: wbAwardRefs[String(e.id)] })) } : null),
|
||||
[wb, wbAwardRefs],
|
||||
);
|
||||
// Always-current copy of the entry callsign, so the UDP event handlers
|
||||
// (which live in a []-deps effect with a stale `callsign` closure) can
|
||||
// tell whether an incoming DX call actually changed anything.
|
||||
@@ -2542,7 +2577,7 @@ export default function App() {
|
||||
case 'worked':
|
||||
return (
|
||||
<div className="h-full w-full min-h-0 flex flex-col bg-card border border-border rounded-lg overflow-hidden">
|
||||
<WorkedBeforeGrid wb={wb} busy={wbBusy} currentCall={callsign} onRowDoubleClicked={(q) => openEdit(q.id as number)}
|
||||
<WorkedBeforeGrid wb={wbWithAwards as any} awardCols={awardCols} busy={wbBusy} currentCall={callsign} onRowDoubleClicked={(q) => openEdit(q.id as number)}
|
||||
onUpdateFromCty={bulkUpdateFromCty} onUpdateFromQRZ={bulkUpdateFromQRZ} onUpdateFromClublog={bulkUpdateFromClublog}
|
||||
onSendTo={bulkSendTo} onSendRecording={bulkSendRecording} onSendEQSL={(ids) => setEqslQsoId(ids[0] ?? null)} />
|
||||
</div>
|
||||
@@ -3225,8 +3260,9 @@ export default function App() {
|
||||
)}
|
||||
|
||||
<RecentQSOsGrid
|
||||
rows={qsos as any}
|
||||
rows={qsosWithAwards as any}
|
||||
total={total}
|
||||
awardCols={awardCols}
|
||||
onRowDoubleClicked={(q) => openEdit(q.id as number)}
|
||||
onUpdateFromCty={bulkUpdateFromCty}
|
||||
onUpdateFromQRZ={bulkUpdateFromQRZ}
|
||||
@@ -3410,7 +3446,7 @@ export default function App() {
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="worked" className="mt-0 flex flex-col min-h-0 flex-1">
|
||||
<WorkedBeforeGrid wb={wb} busy={wbBusy} currentCall={callsign} onRowDoubleClicked={(q) => openEdit(q.id as number)}
|
||||
<WorkedBeforeGrid wb={wbWithAwards as any} awardCols={awardCols} busy={wbBusy} currentCall={callsign} onRowDoubleClicked={(q) => openEdit(q.id as number)}
|
||||
onUpdateFromCty={bulkUpdateFromCty} onUpdateFromQRZ={bulkUpdateFromQRZ} onUpdateFromClublog={bulkUpdateFromClublog} onSendTo={bulkSendTo} onSendRecording={bulkSendRecording}
|
||||
onSendEQSL={(ids) => setEqslQsoId(ids[0] ?? null)} />
|
||||
</TabsContent>
|
||||
|
||||
Reference in New Issue
Block a user