Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

877 B
Raw Blame
const KEY = 'trek_dash_collections_shown';

/**
 * How many lists the dashboard's collections widget showed last time. While the
 * lists load, the widget stands in with that many placeholder badges, so it
 * opens at the height it will have and the widgets under it stay put (#3009).
 * Null when nothing is remembered yet, or storage is unavailable.
 */
export function readShownCollections(): number | null {
  try {
    const raw = localStorage.getItem(KEY);
    if (raw == null) return null;
    const n = Number.parseInt(raw, 10);
    return Number.isInteger(n) && n >= 0 && n <= 6 ? n : null;
  } catch {
    return null;
  }
}

export function rememberShownCollections(count: number): void {
  try {
    localStorage.setItem(KEY, String(Math.max(0, Math.min(6, count))));
  } catch {
    /* storage blocked: the widget just opens at its empty height next time */
  }
}