diff --git a/src/services/BlockService/TransitionProcessor.tsx b/src/services/BlockService/TransitionProcessor.tsx index 09c0099e..8d9dedeb 100644 --- a/src/services/BlockService/TransitionProcessor.tsx +++ b/src/services/BlockService/TransitionProcessor.tsx @@ -33,6 +33,11 @@ export const processTransition = async (flow: Flow, path: keyof Flow, params: Pa transitionDetails = transitionAttr; } + // if number provided, transform to object with default values + if (typeof transitionDetails === "number") { + transitionDetails = {duration: transitionDetails}; + } + // cannot transition if details are not present if (!transitionDetails || transitionDetails instanceof Promise) { return; @@ -44,7 +49,7 @@ export const processTransition = async (flow: Flow, path: keyof Flow, params: Pa } // defaults interruptable to false if not found - if (!transitionDetails.interruptable) { + if (transitionDetails.interruptable == null) { transitionDetails.interruptable = false; } diff --git a/src/types/Block.ts b/src/types/Block.ts index 46225163..614a2a3f 100644 --- a/src/types/Block.ts +++ b/src/types/Block.ts @@ -21,9 +21,9 @@ export type Block = { ((params: Params) => Promise); chatDisabled?: boolean | ((params: Params) => boolean) | ((params: Params) => Promise); isSensitive?: boolean | ((params: Params) => boolean) | ((params: Params) => Promise); - transition?: {duration: number, interruptable?: boolean} | void | - ((params: Params) => {duration: number, interruptable?: boolean} | void) | - ((params: Params) => Promise<{duration: number, interruptable?: boolean} | void>); + transition?: number | {duration: number, interruptable?: boolean} | void | + ((params: Params) => number | {duration: number, interruptable?: boolean} | void) | + ((params: Params) => Promise); // post-processing attributes (runs after user input) function?: ((params: Params) => void) | ((params: Params) => Promise);