Skip to content

Commit fae4b17

Browse files
Minor changes/fixes (#301)
* Update ical.js.gs according #259 * Update Helpers.gs as in 271 and discord * Update Helpers.gs increased max. number of results returned by CalendarList.list() to prevent creation of new target calendars in case of high amount of calendars. * Update Helpers.gs
1 parent 8399269 commit fae4b17

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

Helpers.gs

+19-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function fetchSourceCalendars(sourceCalendarURLs){
107107
* @return {Calendar} The calendar retrieved or created
108108
*/
109109
function setupTargetCalendar(targetCalendarName){
110-
var targetCalendar = Calendar.CalendarList.list({showHidden: true}).items.filter(function(cal) {
110+
var targetCalendar = Calendar.CalendarList.list({showHidden: true, maxResults: 250}).items.filter(function(cal) {
111111
return ((cal.summaryOverride || cal.summary) == targetCalendarName) &&
112112
(cal.accessRole == "owner" || cal.accessRole == "writer");
113113
})[0];
@@ -172,6 +172,15 @@ function parseResponses(responses){
172172
}
173173
});
174174
}
175+
176+
//No need to process calcelled events as they will be added to gcal's trash anyway
177+
result = result.filter(function(event){
178+
try{
179+
return (event.getFirstPropertyValue('status').toString().toLowerCase() != "cancelled");
180+
}catch(e){
181+
return true;
182+
}
183+
});
175184

176185
result.forEach(function(event){
177186
if (!event.hasProperty('uid')){
@@ -187,7 +196,7 @@ function parseResponses(responses){
187196
icsEventsIds.push(event.getFirstPropertyValue('uid').toString());
188197
}
189198
});
190-
199+
191200
return result;
192201
}
193202

@@ -511,6 +520,14 @@ function checkSkipEvent(event, icalEvent){
511520
rrule.setValue(recur);
512521
}
513522

523+
var exDates = event.getAllProperties('exdate');
524+
exDates.forEach(function(e){
525+
var ex = new ICAL.Time.fromString(e.getFirstValue().toString());
526+
if (ex < newStartDate){
527+
event.removeProperty(e);
528+
}
529+
});
530+
514531
var rdates = event.getAllProperties('rdate');
515532
rdates.forEach(function(r){
516533
var vals = r.getValues();

ical.js.gs

+4-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ ICAL.helpers = {
8989
if (
9090
reqTzid.hasOwnProperty(i) &&
9191
!vtimezones[i] &&
92-
ICAL.TimezoneService.has(i)
92+
ICAL.TimezoneService.has(i) &&
93+
ICAL.TimezoneService.get(i).component
94+
9395
) {
9496
vcal.addSubcomponent(ICAL.TimezoneService.get(i).component);
9597
}
@@ -1320,7 +1322,7 @@ ICAL.design = (function() {
13201322
/**
13211323
* Can be set to false to make the parser more lenient.
13221324
*/
1323-
strict: true,
1325+
strict: false,
13241326

13251327
/**
13261328
* The default set for new properties and components if none is specified.

0 commit comments

Comments
 (0)