Skip to content

Commit

Permalink
Minor changes/fixes (#301)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jonas0b1011001 authored Jan 11, 2023
1 parent 8399269 commit fae4b17
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
21 changes: 19 additions & 2 deletions Helpers.gs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function fetchSourceCalendars(sourceCalendarURLs){
* @return {Calendar} The calendar retrieved or created
*/
function setupTargetCalendar(targetCalendarName){
var targetCalendar = Calendar.CalendarList.list({showHidden: true}).items.filter(function(cal) {
var targetCalendar = Calendar.CalendarList.list({showHidden: true, maxResults: 250}).items.filter(function(cal) {
return ((cal.summaryOverride || cal.summary) == targetCalendarName) &&
(cal.accessRole == "owner" || cal.accessRole == "writer");
})[0];
Expand Down Expand Up @@ -172,6 +172,15 @@ function parseResponses(responses){
}
});
}

//No need to process calcelled events as they will be added to gcal's trash anyway
result = result.filter(function(event){
try{
return (event.getFirstPropertyValue('status').toString().toLowerCase() != "cancelled");
}catch(e){
return true;
}
});

result.forEach(function(event){
if (!event.hasProperty('uid')){
Expand All @@ -187,7 +196,7 @@ function parseResponses(responses){
icsEventsIds.push(event.getFirstPropertyValue('uid').toString());
}
});

return result;
}

Expand Down Expand Up @@ -511,6 +520,14 @@ function checkSkipEvent(event, icalEvent){
rrule.setValue(recur);
}

var exDates = event.getAllProperties('exdate');
exDates.forEach(function(e){
var ex = new ICAL.Time.fromString(e.getFirstValue().toString());
if (ex < newStartDate){
event.removeProperty(e);
}
});

var rdates = event.getAllProperties('rdate');
rdates.forEach(function(r){
var vals = r.getValues();
Expand Down
6 changes: 4 additions & 2 deletions ical.js.gs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ ICAL.helpers = {
if (
reqTzid.hasOwnProperty(i) &&
!vtimezones[i] &&
ICAL.TimezoneService.has(i)
ICAL.TimezoneService.has(i) &&
ICAL.TimezoneService.get(i).component

) {
vcal.addSubcomponent(ICAL.TimezoneService.get(i).component);
}
Expand Down Expand Up @@ -1320,7 +1322,7 @@ ICAL.design = (function() {
/**
* Can be set to false to make the parser more lenient.
*/
strict: true,
strict: false,

/**
* The default set for new properties and components if none is specified.
Expand Down

0 comments on commit fae4b17

Please sign in to comment.