fix(calendar): properly store the vevent is the correct order for reccurence and reccurence-id

This commit is contained in:
Hivert Quentin
2025-02-19 16:14:34 +01:00
parent a1e8a5c4af
commit d15f0ee804
2 changed files with 110 additions and 52 deletions

View File

@@ -25,6 +25,7 @@
#import <Foundation/NSString.h>
#import <NGCards/iCalEvent.h>
#import <NGCards/iCalDateTime.h>
#import <NGCards/iCalRepeatableEntityObject.h>
#import "iCalCalendar+SOGo.h"
@@ -97,7 +98,29 @@
elements = [self allObjects];
count = [elements count];
if (count)
{
element = [elements objectAtIndex: 0];
if(count >1)
{
//If there more than one event, it may because there is the main reccurent event and some exceptions with reccurenceId
//It's important to fetch the "main" vevent and not the other.
NSEnumerator *elementEnum;
NSCalendarDate *recurrenceId;
CardGroup *elem;
elementEnum = [elements objectEnumerator];
while((elem = [elementEnum nextObject]))
{
recurrenceId = [(iCalDateTime *) [elem uniqueChildWithTag: @"recurrence-id"] dateTime];
if(recurrenceId)
continue;
else
{
element = elem;
break;
}
}
}
}
else
{
//NSLog(@"ERROR: given calendar contains no elements: %@", self);