RRule: move filtering of empty values to inside the widget.

master
Tom Hacohen 5 years ago
parent 09ff87ba33
commit 7b22e0e76b

@ -220,16 +220,7 @@ class EventEdit extends React.PureComponent<PropsType> {
}
}
if (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('rrule', new ICAL.Recur(this.state.rrule!));
}
event.component.updatePropertyWithValue('last-modified', ICAL.Time.now());

@ -80,7 +80,15 @@ interface PropsType {
export default function RRule(props: PropsType) {
const options = props.rrule;
function updateRule(newOptions: Partial<RRuleOptions>): void {
const updatedOptions = { ...options, ...newOptions };
const updatedOptions: RRuleOptions = { ...options, ...newOptions };
for (const key of Object.keys(updatedOptions)) {
const value = updatedOptions[key];
if ((value === undefined) || (value?.length === 0)) {
delete updatedOptions[key];
continue;
}
}
props.onChange(updatedOptions);
}
function getEnds(): Ends {

Loading…
Cancel
Save