I'm currently working on a project using the schedule component, and I can't seem to work out why the "actionBegin" function built into the component doesn't work properly when dealing with an async callback and also why events are added if "args.cancel" is triggered by an await parameter
This is the issue:
actionBegin={ async (args: ActionEventArgs) => {
const { requestType, changedRecords, addedRecords, deletedRecords } = args
let performAction: any = false
let isOnLine = navigator.onLine
if (requestType === "eventCreate") {
if (addedRecords?.length) performAction = await addSchedule(addedRecords)
} else if (requestType === "eventChange") {
if (addedRecords?.length) performAction = await addSchedule(addedRecords)
if (changedRecords?.length) performAction = await changeSchedule(changedRecords)
if (deletedRecords?.length) performAction = await popSchedule(deletedRecords)
} else if (requestType === "eventRemove") {
if (deletedRecords?.length) performAction = await popSchedule(deletedRecords)
}
console.log(performAction === false && (requestType === "eventChange" || requestType === "eventRemove" || requestType === "eventCreate") && isOnLine === false)
console.log(`isOnLine-${isOnLine}`)
console.log(`performAction-${performAction}`)
if (performAction === false && (requestType === "eventChange" || requestType === "eventRemove" || requestType === "eventCreate") && isOnLine === false) args.cancel = true
} }