From 6379e2cd1fb4cb36fa023b5bea2ddb588eeac864 Mon Sep 17 00:00:00 2001 From: rouggy Date: Sat, 20 Jun 2026 02:32:32 +0200 Subject: [PATCH] fix: persistence on columns awards --- frontend/src/components/RecentQSOsGrid.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/RecentQSOsGrid.tsx b/frontend/src/components/RecentQSOsGrid.tsx index f8e91bf..3cfe28a 100644 --- a/frontend/src/components/RecentQSOsGrid.tsx +++ b/frontend/src/components/RecentQSOsGrid.tsx @@ -1,4 +1,4 @@ -import { useCallback, useMemo, useRef, useState } from 'react'; +import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { AllCommunityModule, ModuleRegistry, themeQuartz, type ColDef, type ColumnState, type GridReadyEvent, type RowDoubleClickedEvent, @@ -288,6 +288,18 @@ export function RecentQSOsGrid({ rows, onRowDoubleClicked, onRowSelected, onUpda if (state) saveState(COL_STATE_KEY, state); }, []); + // The award columns load asynchronously; when they arrive (or change) the + // columnDefs memo is rebuilt and AG Grid re-applies each colDef's `hide` + // default — wiping the user's saved visibility (award columns reappear, + // manually-shown ones like LoTW sent vanish). Re-apply the saved state after + // every rebuild so the user's choices win. No-op before the grid is ready. + useEffect(() => { + const api = gridRef.current?.api; + if (!api) return; + const local = loadLocal(COL_STATE_KEY); + if (local) api.applyColumnState({ state: local as ColumnState[], applyOrder: true }); + }, [awardCols]); + function handleRowDoubleClicked(e: RowDoubleClickedEvent) { if (e.data && onRowDoubleClicked) onRowDoubleClicked(e.data); }