1
0
Fork 0
mirror of synced 2024-08-06 05:38:40 +12:00

Fix bug where adding a confirmation step to a button action chain would break event context in further actions

This commit is contained in:
Andrew Kingston 2024-05-02 10:48:44 +01:00
parent e72a3f4677
commit b08bfc2517

View file

@ -542,16 +542,22 @@ export const enrichButtonActions = (actions, context) => {
// then execute the rest of the actions in the chain // then execute the rest of the actions in the chain
const result = await callback() const result = await callback()
if (result !== false) { if (result !== false) {
// Generate a new total context to pass into the next enrichment // Generate a new total context for the next enrichment
buttonContext.push(result) buttonContext.push(result)
const newContext = { ...context, actions: buttonContext } const newContext = { ...context, actions: buttonContext }
// Enrich and call the next button action if there is more than one action remaining // Enrich and call the next button action if there is more
// than one action remaining
const next = enrichButtonActions( const next = enrichButtonActions(
actions.slice(i + 1), actions.slice(i + 1),
newContext newContext
) )
resolve(typeof next === "function" ? await next() : true) if (typeof next === "function") {
// Pass the event context back into the new action chain
resolve(await next(eventContext))
} else {
resolve(true)
}
} else { } else {
resolve(false) resolve(false)
} }