refactor(pdf): the remembered preview switches move to utils

This commit is contained in:
Maurice
2026-10-12 21:14:28 +00:00
parent 8832632b4e
commit 18baafe57d
3 changed files with 55 additions and 17 deletions
+1 -17
View File
@@ -8,6 +8,7 @@ import type { Trip, Day, Place, Category, AssignmentsMap, DayNote, DistanceUnit,
import { isDayInAccommodationRange, getDayOrder } from '../../utils/dayOrder'
import { hidesOnMiddleDay, getTransportForDay, getMergedItems, getSpanPhase, getDisplayTimeForDay } from '../../utils/dayMerge'
import { safeHexColor } from '../../utils/safeColor'
import { pdfSwitchOn, rememberPdfSwitch } from '../../utils/pdfSwitch'
import { renderIconMarkup } from '../../utils/iconMarkup'
import { formatMoney, formatMoneySum, formatClockTime, splitReservationDateTime, type MoneyEntry } from '../../utils/formatters'
import { useSettingsStore } from '../../store/settingsStore'
@@ -38,23 +39,6 @@ const PAGE_BREAK_KEY = 'trek_pdf_page_break_per_day'
*/
const TRANSPORT_NOTES_KEY = 'trek_pdf_transport_notes'
/** A preview switch that is on unless it was turned off; both default to on. */
function pdfSwitchOn(key: string): boolean {
try {
return localStorage.getItem(key) !== '0'
} catch {
return true
}
}
function rememberPdfSwitch(key: string, on: boolean): void {
try {
localStorage.setItem(key, on ? '1' : '0')
} catch {
// A blocked localStorage costs the preference, not the export.
}
}
/* The overlay is imperative DOM, so the switch from Settings/ToggleSwitch is
rebuilt here rather than rendered — as static markup it would carry no
behaviour. Same geometry and the same tokens, so it reads as the same control. */