Skip to content

Commit

Permalink
- Update LAST-MODIFIED property on each and every change
Browse files Browse the repository at this point in the history
- Update DTSTAMP property together with LAST-MODIFIED
- Use UTC on LAST-MODIFIED, DTSTAMP and CREATED
  • Loading branch information
DeepDiver1975 committed Sep 12, 2018
1 parent 154c3f9 commit eba232a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions js/app/controllers/calcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEven

fcEvent.event.removeAllProperties('exdate');
fcEvent.event.addProperty(exdateProp);
fcEvent.vevent.touch();
VEventService.update(vevent).then(function() {
fc.elm.fullCalendar('refetchEventSources', vevent.calendar.fcEventSource);
});
Expand Down Expand Up @@ -263,6 +264,7 @@ app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEven
}).then(function(result) {
// was the event moved to another calendar?
if (result.calendar === oldCalendar) {
fcEvt.vevent.touch();
VEventService.update(vevent).then(function() {
fc.elm.fullCalendar('removeEvents', fcEvent.id);

Expand All @@ -281,6 +283,9 @@ app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEven
else if(reason === 'deleteOccurrence') {
deleteOccurrence(vevent, fcEvent);
}
else {
throw reason;
}
});
},
eventResize: function (fcEvent, delta, revertFunc) {
Expand Down
9 changes: 5 additions & 4 deletions js/app/factory/icalFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ app.service('ICalFactory', function(constants) {

const event = new ICAL.Component('vevent');
comp.addSubcomponent(event);
const nowInUtc = ICAL.Time.fromJSDate(new Date(), true);

event.updatePropertyWithValue('created', ICAL.Time.now());
event.updatePropertyWithValue('dtstamp', ICAL.Time.now());
event.updatePropertyWithValue('last-modified', ICAL.Time.now());
event.updatePropertyWithValue('created', nowInUtc);
event.updatePropertyWithValue('dtstamp', nowInUtc);
event.updatePropertyWithValue('last-modified', nowInUtc);
event.updatePropertyWithValue('uid', uid);

//add a dummy dtstart, so it's a valid ics
event.updatePropertyWithValue('dtstart', ICAL.Time.now());
event.updatePropertyWithValue('dtstart', nowInUtc);

return comp;
};
Expand Down
4 changes: 3 additions & 1 deletion js/app/models/veventModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ app.factory('VEvent', function(TimezoneService, FcEvent, SimpleEvent, ICalFactor
*/
iface.touch = function() {
const vevent = context.comp.getFirstSubcomponent('vevent');
vevent.updatePropertyWithValue('last-modified', ICAL.Time.now());
const nowInUtc = ICAL.Time.fromJSDate(new Date(), true);
vevent.updatePropertyWithValue('last-modified', nowInUtc);
vevent.updatePropertyWithValue('dtstamp', nowInUtc);
};

return iface;
Expand Down

0 comments on commit eba232a

Please sign in to comment.