diff --git a/apps/api/src/broker/expand.ts b/apps/api/src/broker/expand.ts index e052b23..63888b2 100644 --- a/apps/api/src/broker/expand.ts +++ b/apps/api/src/broker/expand.ts @@ -64,6 +64,8 @@ export interface CalendarOccurrence { allDay: boolean location: string | null description: string | null + /** True when this occurrence belongs to a recurring series (has RRULE). False for single events. */ + hasRrule: boolean } /** @@ -219,8 +221,11 @@ export function expandOccurrences( const occurrences: CalendarOccurrence[] = [] + // Capture once — used in both the non-recurring and recurring branches to populate hasRrule. + const isRecurring = event.isRecurring() + // --- 4. Non-recurring event: single occurrence check --- - if (!event.isRecurring()) { + if (!isRecurring) { if (dtstart.compare(rangeStart) >= 0 && dtstart.compare(rangeEnd) < 0) { // Use ICAL.Event.endDate which derives end from DTEND, or DTSTART+DURATION, or sensible default. // Do NOT use getFirstPropertyValue('dtend') directly — events with only DURATION set return null, @@ -253,6 +258,7 @@ export function expandOccurrences( allDay, location: event.location ?? null, description: event.description ?? null, + hasRrule: isRecurring, // always false in the non-recurring branch }) } return occurrences @@ -299,6 +305,7 @@ export function expandOccurrences( allDay, location: event.location ?? null, description: event.description ?? null, + hasRrule: isRecurring, // always true in the recurring branch }) }