JavaScript AppleScript deleting calendar events is slow
Hey guys,
I'm working on a jxa javascript applescript project that publishes events to a calendar.
Before publishing the events the script has to delete all the existing events on a given day.f
In general this is working but deleting events from a calendar is INCREDIBLY slow!
It takes about 15-20 seconds to just delete one single event. This varies a little bit based on the number of events in that calendar.
What I do is that I get the events via the whose method and then run each events delete() method:
while(calendarEventsToDelete.length > 0){
if(calendarEventsToDelete){
console.log("Current Length: " + calendarEventsToDelete.length);
calendarEventsToDelete[0].delete();
}else{
break;
}
}
Main Question: Is there a way that needs less time for deleting events from a calendar?
In Addition: I'm using a while loop that checks for the calendarEventsToDelete list length because otherwise the events won't be deleted at all.
Thank you for your help,
best,
nelic