fix: bug when deleting an award reference which was not saved.
This commit is contained in:
@@ -1007,11 +1007,15 @@ export default function App() {
|
||||
// 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 }[]>([]);
|
||||
// Bumped whenever award definitions are saved so the grid columns AND the
|
||||
// per-QSO refs re-fetch — the ref/name display choice is computed live, so
|
||||
// changing it updates ALL contacts (old included) with no restart.
|
||||
const [awardsVersion, setAwardsVersion] = useState(0);
|
||||
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(() => {});
|
||||
}, []);
|
||||
}, [awardsVersion]);
|
||||
const [qsoAwardRefs, setQsoAwardRefs] = useState<Record<string, Record<string, string>>>({});
|
||||
useEffect(() => {
|
||||
const ids = (qsos as any[]).map((q) => q.id).filter(Boolean);
|
||||
@@ -1019,7 +1023,7 @@ export default function App() {
|
||||
let alive = true;
|
||||
AwardRefsForQSOs(ids as any).then((m: any) => { if (alive) setQsoAwardRefs(m ?? {}); }).catch(() => {});
|
||||
return () => { alive = false; };
|
||||
}, [qsos, awardCols.length]);
|
||||
}, [qsos, awardCols.length, awardsVersion]);
|
||||
const qsosWithAwards = useMemo(
|
||||
() => (qsos as any[]).map((q) => ({ ...q, award_refs: qsoAwardRefs[String(q.id)] })),
|
||||
[qsos, qsoAwardRefs],
|
||||
@@ -1031,7 +1035,7 @@ export default function App() {
|
||||
let alive = true;
|
||||
AwardRefsForQSOs(ids as any).then((m: any) => { if (alive) setWbAwardRefs(m ?? {}); }).catch(() => {});
|
||||
return () => { alive = false; };
|
||||
}, [wb, awardCols.length]);
|
||||
}, [wb, awardCols.length, awardsVersion]);
|
||||
const wbWithAwards = useMemo(
|
||||
() => (wb ? { ...wb, entries: ((wb.entries ?? []) as any[]).map((e) => ({ ...e, award_refs: wbAwardRefs[String(e.id)] })) } : null),
|
||||
[wb, wbAwardRefs],
|
||||
@@ -4169,7 +4173,7 @@ export default function App() {
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="awards" className="flex-1 min-h-0 p-0">
|
||||
<AwardsPanel onEditQSO={openEdit} />
|
||||
<AwardsPanel onEditQSO={openEdit} onAwardsChanged={() => setAwardsVersion((v) => v + 1)} />
|
||||
</TabsContent>
|
||||
|
||||
{contestTabEnabled && (
|
||||
|
||||
Reference in New Issue
Block a user