Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctx.wizard.step could unwrap before return #1965

Open
MKRhere opened this issue Mar 4, 2024 · 0 comments
Open

ctx.wizard.step could unwrap before return #1965

MKRhere opened this issue Mar 4, 2024 · 0 comments
Labels

Comments

@MKRhere
Copy link
Member

MKRhere commented Mar 4, 2024

Currently wizard steps have no idea whether the next/previous middleware are MiddlewareFn or MiddlewareObj, leading to cases like:

ctx.wizard.back();

// This expression is not callable.
// Not all constituents of type 'Middleware<unknown>' are callable.
return ctx.wizard.step(ctx, next);

The fix is:

return Composer.unwrap(ctx.wizard.step)(ctx, next);

v5 could make this change:

get step() {
-  return this.steps[this.cursor]
+  return Composer.unwrap(this.steps[this.cursor])
}

Therefore making it always safe to call ctx.wizard.step?.(ctx. next)

@MKRhere MKRhere added the v5 label Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant