diff options
| author | Adam Malczewski <[email protected]> | 2026-03-28 19:26:58 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-03-28 19:26:58 +0900 |
| commit | ab6d09df695c5cdfa21aa8005f00ebf2bd37df2b (patch) | |
| tree | ae4f994a85b2ba52a9c8e8626c6d8ae9dd2e4cf4 /.rules/plan/calendar-phase-2.md | |
| parent | 80b35f3a606753ba804445e120eb9a7f05afef85 (diff) | |
| download | ai-pulse-obsidian-plugin-ab6d09df695c5cdfa21aa8005f00ebf2bd37df2b.tar.gz ai-pulse-obsidian-plugin-ab6d09df695c5cdfa21aa8005f00ebf2bd37df2b.zip | |
split of big plan
Diffstat (limited to '.rules/plan/calendar-phase-2.md')
| -rw-r--r-- | .rules/plan/calendar-phase-2.md | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/.rules/plan/calendar-phase-2.md b/.rules/plan/calendar-phase-2.md new file mode 100644 index 0000000..e1e22ff --- /dev/null +++ b/.rules/plan/calendar-phase-2.md @@ -0,0 +1,41 @@ +# Phase 2: Calendar State (`src/calendar/calendar-state.ts`) + +**Status:** Not started +**Depends on:** Phase 1 (daily-notes.ts — for `indexDailyNotes`, `getDateFromDailyNote`) +**Output file:** `src/calendar/calendar-state.ts` + +--- + +## Overview + +Simple state container with change notifications — replaces Svelte stores. Holds the displayed month, today's date, active file tracking, and the note index. Notifies subscribers on any state change. + +--- + +## Design + +``` +class CalendarState: + - displayedMonth: Moment (current month being viewed) + - today: Moment (refreshed by heartbeat) + - activeFileDate: string | null (date UID of active file, if daily note) + - noteIndex: Map<string, TFile> (date string → file) + - listeners: Set<() => void> + + Methods: + - subscribe(cb): () => void (unsubscribe function) + - setDisplayedMonth(m: Moment): void + - setActiveFile(file: TFile | null): void + - reindex(app: App, rootFolder: string): void + - tick(): void (refresh today) + - notify(): void (call all listeners) +``` + +--- + +## Notes + +- `reindex()` delegates to `indexDailyNotes()` from Phase 1. +- `setActiveFile()` uses `getDateFromDailyNote()` from Phase 1 to determine if the file is a daily note. +- `tick()` updates `today` and calls `notify()` only if the date has changed (day rollover). +- Subscribers are plain callbacks — no framework dependency. |
