Revert "Revert "fix(calendar): Fix issue where EXDATE removes modified occurence. The behavior is now identical to G Agenda. This fix may reduce the 'missing exception error'.""

This reverts commit ec20ea1b45d35f9d63066baf324fa6726b4e910e.
This commit is contained in:
smizrahi
2024-11-12 16:21:12 +01:00
parent 9a9d968756
commit 581b2c1912
+17 -19
View File
@@ -1130,28 +1130,26 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
delta = [masterEndDate timeIntervalSinceDate: [master startDate]]; delta = [masterEndDate timeIntervalSinceDate: [master startDate]];
recurrenceIdRange = [NGCalendarDateRange calendarDateRangeWithStartDate: recurrenceId recurrenceIdRange = [NGCalendarDateRange calendarDateRangeWithStartDate: recurrenceId
endDate: [recurrenceId dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds: delta]]; endDate: [recurrenceId dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds: delta]];
if ([dateRange doesIntersectWithDateRange: recurrenceIdRange]) recordIndex = [self _indexOfRecordMatchingDate: recurrenceId inArray: ma];
if ([dateRange doesIntersectWithDateRange: recurrenceIdRange] && recordIndex == -1) {
[self warnWithFormat:
@"missing exception record for recurrence-id %@ (uid %@), ma = %@, dr = %@, rir = %@",
recurrenceId, [component uid], ma, dateRange, recurrenceIdRange];
}
if ([dateRange doesIntersectWithDateRange: recurrenceIdRange] && recordIndex != -1)
{ {
// The recurrence exception intersects with the date range; // The recurrence exception intersects with the date range;
// find the occurence and replace it with the new record // find the occurence and replace it with the new record
recordIndex = [self _indexOfRecordMatchingDate: recurrenceId inArray: ma]; if ([dateRange containsDate: [component startDate]] ||
if (recordIndex > -1) (endDate && [dateRange containsDate: endDate]))
{ {
if ([dateRange containsDate: [component startDate]] || // We must pass nil to :container here in order to avoid re-entrancy issues.
(endDate && [dateRange containsDate: endDate])) newRecord = [self _fixupRecord: [component quickRecordFromContent: nil container: nil nameInContainer: nil]];
{ [ma replaceObjectAtIndex: recordIndex withObject: newRecord];
// We must pass nil to :container here in order to avoid re-entrancy issues. }
newRecord = [self _fixupRecord: [component quickRecordFromContent: nil container: nil nameInContainer: nil]]; else
[ma replaceObjectAtIndex: recordIndex withObject: newRecord]; // The range doesn't cover the exception; remove it from the records
} [ma removeObjectAtIndex: recordIndex];
else
// The range doesn't cover the exception; remove it from the records
[ma removeObjectAtIndex: recordIndex];
}
else
[self errorWithFormat:
@"missing exception record for recurrence-id %@ (uid %@)",
recurrenceId, [component uid]];
} }
else else
{ {