Skip to content

Commit 56ead83

Browse files
committed
🐛 fix(recurring-events): restrict someday instances without until to 6 events
1 parent 685a9d5 commit 56ead83

File tree

1 file changed

+9
-19
lines changed
  • packages/web/src/views/Forms/EventForm/DateControlsSection/RecurrenceSection/useRecurrence

1 file changed

+9
-19
lines changed

packages/web/src/views/Forms/EventForm/DateControlsSection/RecurrenceSection/useRecurrence/useRecurrence.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,13 @@ export const useRecurrence = (
9595
};
9696
}
9797

98-
return new CompassEventRRule(
99-
{
100-
_id: new ObjectId(), // we do not need the event's actual id here
101-
startDate: startDate!,
102-
endDate: endDate!,
103-
recurrence: { rule: recurrence?.rule as string[] },
104-
},
105-
isSomeday ? { count: 6 } : {}, // default to 6 occurrences for someday events
106-
);
107-
}, [
108-
_startDate,
109-
startDate,
110-
endDate,
111-
hasRecurrence,
112-
recurrence?.rule,
113-
isSomeday,
114-
]);
98+
return new CompassEventRRule({
99+
_id: new ObjectId(), // we do not need the event's actual id here
100+
startDate: startDate!,
101+
endDate: endDate!,
102+
recurrence: { rule: recurrence?.rule as string[] },
103+
});
104+
}, [_startDate, startDate, endDate, hasRecurrence, recurrence?.rule]);
115105

116106
const defaultWeekDay: typeof WEEKDAYS = useMemo(
117107
() =>
@@ -157,9 +147,9 @@ export const useRecurrence = (
157147
endDate: endDate,
158148
recurrence: { rule: [] },
159149
},
160-
rruleOptions,
150+
{ ...rruleOptions, count: isSomeday ? 6 : rruleOptions.count }, // default to 6 occurrences for someday events
161151
),
162-
[startDate, endDate, rruleOptions],
152+
[startDate, endDate, rruleOptions, isSomeday],
163153
);
164154

165155
const rule = useMemo(() => JSON.stringify(rrule.toRecurrence()), [rrule]);

0 commit comments

Comments
 (0)