I’ve been looking to build out the excellent “Process Meeting Notes” action from @nahumck by adding another step to push any follow up meeting requests into Fantasical.
While I’m still largely new to Drafts, I’ve come up with the following code which is largely based on this example from the scripting manual.
/* --- Fantastical --- */
for (var line of lines) {
if (line.includes("[cal]")) {
const baseURL = "x-fantastical3://parse?";
var event = line.replace("[cal]","");
event = event.trim();
// Use CallbackURL object to open URL in Fantastical.
var cb = CallbackURL.create();
cb.baseURL = baseURL;
cb.addParameter("sentence", line);
//Open and wait for result
var success = cb.open();
if (success) {
console.log("Event created in Fantastical");
}
else { // something went wrong or was cancelled
console.log(cb.status);
if (cb.status == "cancelled") {
context.cancel();
}
else {
context.fail();
}
}
}
}
The issue I’m having is that when the action runs, all the steps seem to work fine. Everything goes where it needs to, Fantastical opens up with the relevant details etc … but Drafts as a whole tends to then hang.
The buffer icon appears next to the name of the action and the app becomes pretty unresponsive until I force close it and open it up again.
Can anyone potentially help to point out where I’m going wrong? Am I missing something from my code?
Thanks a lot for your help in advance.