reset options if freq changes

master
Tal Leibman 4 years ago committed by Tom Hacohen
parent fb8f3ff574
commit f64169385e

@ -120,7 +120,12 @@ interface PropsType {
export default function RRule(props: PropsType) { export default function RRule(props: PropsType) {
const options = props.rrule; const options = props.rrule;
function updateRule(newOptions: Partial<RRuleOptions>): void { function updateRule(newOptions: Partial<RRuleOptions>): void {
const updatedOptions: RRuleOptions = { ...options, ...newOptions }; let updatedOptions: RRuleOptions;
if (!!options.freq && !!newOptions.freq && options.freq !== newOptions.freq) {
updatedOptions = { freq: newOptions.freq };
} else {
updatedOptions = { ...options, ...newOptions } ;
}
for (const key of Object.keys(updatedOptions)) { for (const key of Object.keys(updatedOptions)) {
const value = updatedOptions[key]; const value = updatedOptions[key];

Loading…
Cancel
Save