mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
refactor(pdf): the remembered preview switches move to utils
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user