-
-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix event ICS download button file content #1390
Fix event ICS download button file content #1390
Conversation
@smncd is attempting to deploy a commit to the rallly Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
apps/web/src/components/add-to-calendar-button.tsx (1)
122-126
: Approved: ICS file download issue resolvedThe changes successfully address the PR objective by directly setting the ICS file content to the
href
attribute, which should resolve the compatibility issue with calendar applications.However, I have a few suggestions to improve the code further:
- Consider adding error handling for potential issues with the
ics()
function:try { const data = ics(calendarEvent); if (!data) { throw new Error("Failed to generate ICS data"); } // ... rest of the code } catch (error) { console.error("Error generating ICS file:", error); // Handle the error (e.g., show an error message to the user) }
Verify that the
ics()
function's return type is always a string in the correct format for direct assignment tohref
. If not, additional processing might be needed.For better readability, consider extracting the file download logic into a separate function:
const downloadIcsFile = (data: string, filename: string) => { const link = document.createElement("a"); link.href = data; link.download = filename; document.body.appendChild(link); link.click(); document.body.removeChild(link); }; // In the onClick handler: const data = ics(calendarEvent); const filename = `${title.toLowerCase().replace(/\s/g, "-")}.ics`; downloadIcsFile(data, filename);
Nice work @smncd! Thanks for the fix 🙏 |
Happy to help @lukevella! 🥳 |
Solves #1389:
Summary:
The content of the ICS file generated by the download button in
apps/web/src/components/add-to-calendar-button.tsx
is URL-encoded, preventing it from being imported into calendar apps. This PR fixes this.Summary by CodeRabbit