Skip to content

Commit

Permalink
fix(calendar): Update c_startdate field when updating event. Fixes #4376
Browse files Browse the repository at this point in the history
  • Loading branch information
WoodySlum committed Oct 26, 2022
1 parent 9b023f4 commit 549d6a8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
12 changes: 11 additions & 1 deletion SOPE/GDLContentStore/GCSFolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ - (NSException *) writeContent: (NSString *) _content
NSDictionary *currentRow;
NSNumber *storedVersion;
BOOL isNewRecord, hasInsertDelegate, hasUpdateDelegate;
NSCalendarDate *nowDate;
NSCalendarDate *nowDate, *startDate;
NSNumber *now;
EOEntity *quickTableEntity, *storeTableEntity;
NSArray *rows;
Expand All @@ -1002,6 +1002,7 @@ - (NSException *) writeContent: (NSString *) _content
error = nil;
nowDate = [NSCalendarDate date];
now = [NSNumber numberWithUnsignedInt:[nowDate timeIntervalSince1970]];
startDate = nil;

if (doLogStore)
[self logWithFormat:@"should store content: '%@'\n%@", _name, _content];
Expand Down Expand Up @@ -1071,6 +1072,7 @@ - (NSException *) writeContent: (NSString *) _content

[contentRow setObject:_name forKey:@"c_name"];
[contentRow setObject:now forKey:@"c_lastmodified"];

if (isNewRecord)
{
[contentRow setObject:now forKey:@"c_creationdate"];
Expand Down Expand Up @@ -1141,6 +1143,14 @@ - (NSException *) writeContent: (NSString *) _content
}
else
{
// Update c_startdate for appointments
if ([theComponent respondsToSelector:@selector(startDate)]) {
startDate = [theComponent startDate];
if (startDate) {
[quickRow setObject:[NSNumber numberWithUnsignedInt:[startDate timeIntervalSince1970]] forKey:@"c_startdate"];
}
}

if (!ofFlags.sameTableForQuick)
error = (hasUpdateDelegate
? [quickChannel updateRowX: quickRow
Expand Down
3 changes: 3 additions & 0 deletions SOPE/NGCards/iCalCalendar.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
- (void) setMethod: (NSString *) _method;
- (NSString *) method;

// - (void) setStartDate: (NSCalendarDate *) newStartDate;
- (NSCalendarDate *) startDate;

- (NSArray *) events;
- (NSArray *) todos;
- (NSArray *) journals;
Expand Down
19 changes: 19 additions & 0 deletions SOPE/NGCards/iCalCalendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,27 @@ - (void) setMethod: (NSString *) _value
- (NSString *) method
{
return [[self uniqueChildWithTag: @"method"] flattenedValuesForKey: @""];
}

- (NSCalendarDate *) startDate
{
// Parse all dtstart to find the earlier
NSCalendarDate *calendarDate, *tmpCalendarDate;
NSUInteger i;

calendarDate = nil;
if ([[self allObjects] count] > 0) {
calendarDate = [[[[self allObjects] objectAtIndex: 0] uniqueChildWithTag: @"dtstart"] dateTime];
for (i = 0U ; i < [[self allObjects] count] ; i++) {
tmpCalendarDate = [[[[self allObjects] objectAtIndex: i] uniqueChildWithTag: @"dtstart"] dateTime];
if ([tmpCalendarDate timeIntervalSince1970] < [calendarDate timeIntervalSince1970]) calendarDate = tmpCalendarDate;
}
}

return calendarDate;
}


- (void) addToEvents: (iCalEvent *) _event
{
[self addChild: _event];
Expand Down
2 changes: 1 addition & 1 deletion UI/WebServerResources/js/Common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion UI/WebServerResources/js/Common.js.map

Large diffs are not rendered by default.

0 comments on commit 549d6a8

Please sign in to comment.