From 83a8708d6091c67e8f550205568d05ae76f3d9a9 Mon Sep 17 00:00:00 2001 From: rouggy Date: Thu, 30 Jul 2026 21:49:25 +0200 Subject: [PATCH] fix: remember the award sort, and the grey line, across restarts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sort choice is now written through writeUiPref and both keys are registered as portable, so they travel with a copied data/ folder like every other UI preference. Registering them is the part that matters: writeUiPref stores to the DB, but only keys on the portable list are read BACK at startup. A key written and never restored looks exactly like one that was never saved — which is what would have happened here. The grey-line toggle had the same gap. It called writeUiPref from the day it was written but was never added to the list, so it came back off on the next launch. Found while adding the award keys beside it. --- frontend/src/components/AwardsPanel.tsx | 21 +++++++++++++++++---- frontend/src/lib/uiPref.ts | 2 ++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/AwardsPanel.tsx b/frontend/src/components/AwardsPanel.tsx index e096ce1..949768b 100644 --- a/frontend/src/components/AwardsPanel.tsx +++ b/frontend/src/components/AwardsPanel.tsx @@ -8,6 +8,7 @@ import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@ import { cn } from '@/lib/utils'; import { AwardEditor } from '@/components/AwardEditor'; import { useI18n } from '@/lib/i18n'; +import { writeUiPref } from '@/lib/uiPref'; type BandCount = { band: string; worked: number; confirmed: number }; type AwardRef = { @@ -195,11 +196,23 @@ export function AwardsPanel({ onEditQSO, onAwardsChanged }: { onEditQSO?: (id: n // is how award lists are published and how an operator reads a paper list; // description answers the other question — "have I worked anything in // Alicante" — which reference order scatters across the whole table. - const [refSort, setRefSort] = useState<'ref' | 'name'>('ref'); - const [refSortDir, setRefSortDir] = useState<'asc' | 'desc'>('asc'); + // Remembered through writeUiPref rather than localStorage, so the choice + // travels with a copied data/ folder like every other UI preference here. + const [refSort, setRefSort] = useState<'ref' | 'name'>( + () => (localStorage.getItem('opslog.awardRefSort') === 'name' ? 'name' : 'ref')); + const [refSortDir, setRefSortDir] = useState<'asc' | 'desc'>( + () => (localStorage.getItem('opslog.awardRefSortDir') === 'desc' ? 'desc' : 'asc')); const toggleRefSort = (k: 'ref' | 'name') => { - if (k === refSort) setRefSortDir((d) => (d === 'asc' ? 'desc' : 'asc')); - else { setRefSort(k); setRefSortDir('asc'); } + if (k === refSort) { + const d = refSortDir === 'asc' ? 'desc' : 'asc'; + setRefSortDir(d); + writeUiPref('opslog.awardRefSortDir', d); + } else { + setRefSort(k); + setRefSortDir('asc'); + writeUiPref('opslog.awardRefSort', k); + writeUiPref('opslog.awardRefSortDir', 'asc'); + } }; const filteredRefs = useMemo(() => { diff --git a/frontend/src/lib/uiPref.ts b/frontend/src/lib/uiPref.ts index 4564dd8..0d58af4 100644 --- a/frontend/src/lib/uiPref.ts +++ b/frontend/src/lib/uiPref.ts @@ -28,6 +28,8 @@ const PORTABLE_KEYS = [ 'opslog.groupDigitalSlots', // matrix + cluster: all digital modes count as ONE (DXCC-style) instead of per-mode slots 'opslog.clusterShowFilters', // cluster filter sidebar shown (tab + Main pane) 'opslog.mapBasemap', // world map basemap (light / street / satellite) + 'opslog.mapGreyline', // world map: grey line (day/night terminator) shown + 'opslog.awardRefSort', 'opslog.awardRefSortDir', // award reference table: sort column and direction // Cluster filter selections — restored on reopen. 'opslog.clusterFilterSource', 'opslog.clusterGroup', 'opslog.clusterBands', 'opslog.clusterLockBand', 'opslog.clusterLockMode', 'opslog.clusterStatusFilter',