@@ -52,14 +52,20 @@ const configureDateSequence: MakeDateSequenceFn = (rRule, exDate, prevStartDate,
5252 dtstart : prevStartDateUTC ,
5353 } ) ) ;
5454 if ( currentOptions . count || currentOptions . until ) {
55- return rruleSet . all ( )
55+ return {
56+ options : currentOptions ,
57+ dates : rruleSet . all ( )
5658 // we shouldn't use `new Date(string)` because this function has different results in Safari
57- . map ( nextDate => moment ( formatDateToString ( nextDate ) ) . toDate ( ) ) ;
59+ . map ( nextDate => moment ( formatDateToString ( nextDate ) ) . toDate ( ) ) ,
60+ } ;
5861 }
5962 const leftBound = prevStartDateUTC ;
6063 const rightBound = moment ( getUTCDate ( nextStartDate ! ) ) . toDate ( ) ;
61- return rruleSet . between ( leftBound , rightBound , true )
62- . map ( nextDate => moment ( formatDateToString ( nextDate ) ) . toDate ( ) ) ;
64+ return {
65+ options : currentOptions ,
66+ dates : rruleSet . between ( leftBound , rightBound , true )
67+ . map ( nextDate => moment ( formatDateToString ( nextDate ) ) . toDate ( ) ) ,
68+ } ;
6369} ;
6470
6571const configureICalendarRules = ( rRule : string | undefined , options : object ) => {
@@ -100,22 +106,22 @@ const changeCurrentAndFollowing: ChangeFn = (appointmentData, changes, changeAll
100106const getAppointmentSequenceData = (
101107 prevStartDate : Date , startDate : Date , exDate : string , rRule : string | undefined ,
102108) => {
103- const initialSequence : Date [ ] = configureDateSequence ( rRule , exDate ,
109+ const initialSequence = configureDateSequence ( rRule , exDate ,
104110 moment . utc ( prevStartDate ) . toDate ( ) , moment . utc ( startDate ) . toDate ( ) ,
105- ) ;
111+ ) . dates ;
106112 const currentChildIndex = initialSequence
107113 . findIndex ( date => moment ( date ) . isSame ( startDate as Date ) ) ;
108114 return { initialSequence, currentChildIndex } ;
109115} ;
110116
111117export const deleteCurrent : DeleteFn = ( appointmentData ) => {
112- const currentSequence : Date [ ] = configureDateSequence (
118+ const { options , dates } = configureDateSequence (
113119 appointmentData . rRule , appointmentData . exDate ,
114120 moment . utc ( appointmentData . parentData . startDate ) . toDate ( ) ,
115121 moment . utc ( appointmentData . startDate ) . toDate ( ) ,
116122 ) ;
117123
118- if ( currentSequence . length === 1 ) {
124+ if ( ( options . count || options . until ) && dates . length === 1 ) {
119125 return deleteAll ( appointmentData ) ;
120126 }
121127
0 commit comments