From 6d16e6707f4b77cbd285b0d30b951fa85fd5c8dc Mon Sep 17 00:00:00 2001 From: iamdoubz <> Date: Wed, 1 Jul 2026 15:07:47 -0500 Subject: [PATCH] Add calendar store for imported events and PST import progress state --- src/lib/stores/calendar.svelte.ts | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/lib/stores/calendar.svelte.ts diff --git a/src/lib/stores/calendar.svelte.ts b/src/lib/stores/calendar.svelte.ts new file mode 100644 index 0000000..b4d67f7 --- /dev/null +++ b/src/lib/stores/calendar.svelte.ts @@ -0,0 +1,41 @@ +// Imported calendar events (Phase 6, FR-CAL-*). Svelte 5 runes store, same +// shape as settings.svelte.ts/meetings.svelte.ts. + +import { api, events, type CalendarEvent } from "../api"; + +class CalendarStore { + events = $state([]); + loaded = $state(false); + importing = $state(false); + importProgress = $state<{ processed: number; total: number } | null>(null); + importError = $state(null); + + async load() { + try { + this.events = await api.listCalendarEvents(); + } catch { + this.events = []; // no .pst imported yet, or command unreachable + } + if (!this.loaded) { + await events.onPstProgress((p) => (this.importProgress = p)); + this.loaded = true; + } + } + + async importPst(path: string, password?: string) { + this.importing = true; + this.importError = null; + this.importProgress = null; + try { + await api.importPst(path, password); + await this.load(); + } catch (e) { + this.importError = e instanceof Error ? e.message : String(e); + } finally { + this.importing = false; + this.importProgress = null; + } + } +} + +export const calendar = new CalendarStore();