From af65d2044496cb1676b2d3011aac2956ad584c5a Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 14 Jan 2020 21:24:41 +0200 Subject: [PATCH] rrule: handle empty/undefined values --- src/components/EventEdit.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/EventEdit.tsx b/src/components/EventEdit.tsx index bd3c6d8..8f55398 100644 --- a/src/components/EventEdit.tsx +++ b/src/components/EventEdit.tsx @@ -220,7 +220,16 @@ class EventEdit extends React.PureComponent { } } if (this.state.rrule) { - event.component.updatePropertyWithValue('rrule', new ICAL.Recur(this.state.rrule!)); + const rruleData: ICAL.RecurData = {}; + for (const key of Object.keys(this.state.rrule)) { + const value = this.state.rrule[key]; + if ((value === undefined) || (value?.length === 0)) { + continue; + } + + rruleData[key] = value; + } + event.component.updatePropertyWithValue('rrule', new ICAL.Recur(rruleData)); } event.component.updatePropertyWithValue('last-modified', ICAL.Time.now());