Skip to main content

useCalendarEvents

Source: hooks/calendar/useCalendarEvents.ts (78 lines) The useCalendarEvents hook transforms raw task instances from the Convex backend into CalendarKit-compatible event objects with status-based color coding and flicker-free loading.

Data Pipeline


Color Logic

Each task gets a deterministic color from the TASK_COLORS palette, assigned by insertion order. Status overrides change the event color:

Verification Resolution

For “just_show_up” verification style, the hook resolves the effective status by checking if all checkpoint verification statuses are “verified”:

Flicker Prevention

The hook caches the previous event array in a useRef. When the Convex query is refetching (instances === undefined), it returns the cached events instead of an empty array, preventing visual flicker during tab switches or foreground transitions.

Return Value

Events are returned locally and NOT pushed to the CalendarStore Zustand store. This design prevents cascade re-renders in other components (like EventDetailModal) that previously subscribed to the events array.