From 1dd5a9e1b06b0dfa419c122446a9491c0a098571 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 20 Feb 2025 11:29:43 -0800 Subject: [PATCH] Enhancement: better handle recurring events poorly handled by ical library (#4807) --- src/widgets/calendar/integrations/ical.jsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/widgets/calendar/integrations/ical.jsx b/src/widgets/calendar/integrations/ical.jsx index 6c66f80e..77729982 100644 --- a/src/widgets/calendar/integrations/ical.jsx +++ b/src/widgets/calendar/integrations/ical.jsx @@ -51,9 +51,10 @@ export default function Integration({ config, params, setEvents, hideErrors, tim title = `${config.name}: ${title}`; } + // 'dtend' is null for all-day events + const { dtstart, dtend = { value: 0 } } = event; + const eventToAdd = (date, i, type) => { - // 'dtend' is null for all-day events - const { dtstart, dtend = { value: 0 } } = event; const days = dtend.value === 0 ? 1 : (dtend.value - dtstart.value) / (1000 * 60 * 60 * 24); const eventDate = timezone ? DateTime.fromJSDate(date, { zone: timezone }) : DateTime.fromJSDate(date); @@ -72,7 +73,13 @@ export default function Integration({ config, params, setEvents, hideErrors, tim } }; - const recurrenceOptions = event?.recurrenceRule?.origOptions; + let recurrenceOptions = event?.recurrenceRule?.origOptions; + // RRuleSet does not have dtstart, add it manually + if (event?.recurrenceRule && event.recurrenceRule.rrules && event.recurrenceRule.rrules()?.[0]?.origOptions) { + recurrenceOptions = event.recurrenceRule.rrules()[0].origOptions; + recurrenceOptions.dtstart = dtstart.value; + } + if (recurrenceOptions && Object.keys(recurrenceOptions).length !== 0) { try { const rule = new RRule(recurrenceOptions);