fix: retroactively show newly-added table columns for saved column prefs

The Packets column-visibility toggle persists an explicit array of
visible column keys to localStorage. A returning visitor with a
pre-existing saved array (from before the Scope column existed) never
got it shown, since the load path used the saved array verbatim
instead of reconciling it against the current COL_DEFS. Missing keys
now default to visible (unless narrow-viewport-hidden), same as a
fresh visitor gets.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
dborup
2026-07-18 15:39:02 +02:00
co-authored by Claude Sonnet 5
parent e4593e98d4
commit bcbcae1d9d
+9 -1
View File
@@ -2025,7 +2025,15 @@
try {
visibleCols = JSON.parse(localStorage.getItem('packets-visible-cols'));
} catch {}
if (!visibleCols) visibleCols = COL_DEFS.map(c => c.key).filter(k => !defaultHidden.includes(k));
if (!visibleCols) {
visibleCols = COL_DEFS.map(c => c.key).filter(k => !defaultHidden.includes(k));
} else {
// A saved preference predates a since-added column (e.g. "scope") —
// default new columns to visible instead of silently hiding them.
for (const c of COL_DEFS) {
if (!visibleCols.includes(c.key) && !defaultHidden.includes(c.key)) visibleCols.push(c.key);
}
}
const colMenu = document.getElementById('colToggleMenu');
const pktTable = document.getElementById('pktTable');
function applyColVisibility() {