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

fix: Button.Redirect #49

Merged
merged 5 commits into from
Mar 3, 2024
Merged

fix: Button.Redirect #49

merged 5 commits into from
Mar 3, 2024

Conversation

tmm
Copy link
Member

@tmm tmm commented Mar 1, 2024

Button.Redirect isn't working with dynamic content. This PR fixes that.

TODO: Still need to make sure target works correctly across frames.

Copy link

vercel bot commented Mar 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
frog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 2, 2024 8:24pm
frog-auth ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 2, 2024 8:24pm
frog-frame ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 2, 2024 8:24pm

Comment on lines 99 to 102
location && (
<meta property={`fc:frame:button:${index}:target`} content={location} />
target && (
<meta property={`fc:frame:button:${index}:target`} content={target} />
Copy link
Member Author

@tmm tmm Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target is where to post the action to get the location

Comment on lines +254 to +259
if (context.status === 'redirect' && context.buttonIndex) {
const buttonValue = buttonValues[context.buttonIndex - 1]
const location = buttonValue?.replace(/^_r:/, '')
if (!location) throw new Error('location required to redirect')
return c.redirect(location, 302)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to move this down so we have resolved buttonValues based on the context from the current action. Otherwise, redirect location is based on old context values.

@tmm tmm merged commit 79bb79d into main Mar 3, 2024
9 checks passed
@tmm tmm deleted the tmm/fix-redirect branch March 3, 2024 00:20
@github-actions github-actions bot mentioned this pull request Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants