[Bug] await Alert.present() after Calendar.present freezes Scriptable

Hi!!
I don’t know if this bug is already known, or if it’s the correct place to report a bug, so sorry if I posted it in the wrong place :slight_smile:

If the script uses a Calendar or CalendarEvent present function and after presents an alert it just keeps waiting undefined for a response and the alert never shows up.

await CalendarEvent.presentCreate()
/* or */ // await Calendar.presentPicker() 

await (new Alert()).present()

It’s the correct place. You also could have written an email to @simonbs, but I’ve mentioned him now so he should get a notification.

I can confirm this bug. It appears to have something to do with the closing animation of the presented card, because waiting for at least 530 ms afterwards resolves the issue. Older devices might need a longer delay, also depending on their condition.

[rant]Apple, why do you make us all wait for your animations to finish? Older devices sometimes struggle with these animations and therefore get quite slow when they don’t need to and disabeling animations in settings switches to fade animations instead. Apparently even developers need to wait… :man_facepalming:[/rant] (sorry!)

As a workaround, you could do it like that:

// await CalendarEvent.presentCreate()
/* or */ 
await Calendar.presentPicker() 

await new Promise((resolve) => Timer.schedule(530, false, resolve))

await (new Alert()).present()

1 Like

Hi! Thanks a lot for the feedback. I’m glad to hear that you’ve found a workaround. I’ll make sure to look into the underlying cause for this in a future update of Scriptable.

3 Likes

Thank you for all the help!!! :grinning_face_with_smiling_eyes: :grinning_face_with_smiling_eyes: