From d268c0fab6f4f76c4e5ca759c2713898e9e5a0da Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 14 Jan 2020 22:42:38 +0200 Subject: [PATCH] Event Edit: fix handling of recurring events with an until field. It was slightly the wrong type because of typings were wrong. We now explicitly convert it. --- src/components/EventEdit.tsx | 8 +++++++- src/types/ical.js.d.ts | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/EventEdit.tsx b/src/components/EventEdit.tsx index bd3c6d8..22b7d51 100644 --- a/src/components/EventEdit.tsx +++ b/src/components/EventEdit.tsx @@ -107,7 +107,13 @@ class EventEdit extends React.PureComponent { this.state.location = event.location ? event.location : ''; this.state.description = event.description ? event.description : ''; this.state.timezone = event.timezone; - this.state.rrule = this.props.item?.component.getFirstPropertyValue('rrule')?.toJSON(); + const rruleProp = this.props.item?.component.getFirstPropertyValue('rrule'); + if (rruleProp) { + this.state.rrule = rruleProp.toJSON(); + if (rruleProp.until) { + this.state.rrule.until = rruleProp.until; + } + } } else { this.state.uid = uuid.v4(); } diff --git a/src/types/ical.js.d.ts b/src/types/ical.js.d.ts index fe42660..da05e89 100644 --- a/src/types/ical.js.d.ts +++ b/src/types/ical.js.d.ts @@ -175,6 +175,8 @@ declare module 'ical.js' { export class Recur { constructor(data?: RecurData); - public toJSON(): RecurData; + public until: Time | null; + + public toJSON(): Omit & { until?: string }; } }