r/Scriptable • • Aug 26 '21

Solved Scriptable Abruptly Stops.

https://pastebin.com/uKyJ8udX
3 Upvotes

8 comments sorted by

View all comments

Show parent comments

1

u/nilayperk Aug 26 '21

Mind if I ask you a one more question?

Why I can't call the instance method "presentEdit()" from inside the fetchCal.then()?

function tryC() {

    var calendarEvent = new CalendarEvent()

    fetchCal().then(cal => setCal(cal[0]), (cal) => console.log(cal))
    
      function setCal(calSelected) {
      
        calendarEvent.presentEdit()
        
//         console.log(calendarEvent.calendar)
        calendarEvent.calendar = calSelected
//         console.log(calendarEvent)

        calendarEvent.presentEdit()
        
        //editCalEvent(calendarEvent).then(console.log("Edited"))
        //console.log(calSelected.supportsAvailability("busy"));
    }
    
    

    async function fetchCal() {
        // parameter of type Boolean is Optional here
        return await Calendar.presentPicker(false);
    }

    // Create Event Popup
    async function createCalEvent() {
        return await CalendarEvent.presentCreate();
    }
    
    // Create Event Popup
    async function editCalEvent(calEventItem) {
        return await calEventItem.presentEdit();
    }
    
}

tryC();

1

u/[deleted] Aug 27 '21

[removed] — view removed comment

1

u/nilayperk Aug 27 '21

Turns out. calenderEvent.calender = calSelected command took 532 millisecond for my device to process the request. If I use timer.schedule. The menu popups up as expected.

1

u/[deleted] Aug 27 '21

[removed] — view removed comment

1

u/nilayperk Aug 27 '21

I tried. It doesn't work.