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.

614 B
Raw Blame
import type { TourDraft } from '@trek/shared';
import { offlineDb } from './offlineDb';

/** The trip's draft as the account last said it; null while none is cached. */
export async function cachedTourDraft(tripId: number): Promise<TourDraft | null> {
  return (await offlineDb.tourDrafts.get(tripId))?.draft ?? null;
}

/** Keeps the trip's draft as the account answered it, or forgets it for none. */
export async function cacheTourDraft(tripId: number, draft: TourDraft | null): Promise<void> {
  if (draft) await offlineDb.tourDrafts.put({ tripId, draft });
  else await offlineDb.tourDrafts.delete(tripId);
}