-
Notifications
You must be signed in to change notification settings - Fork 120
add share functionality #595
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -120,6 +120,22 @@ export default function Podcasts(): ReactElement { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
window.scrollTo({ top: 0, behavior: 'smooth' }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const handleShare = async (podcast: PodcastData) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (navigator.share) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await navigator.share({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
title: `Check out this ${podcast.type}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
url: podcast.spotifyUrl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Fallback to clipboard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
navigator.clipboard.writeText(podcast.spotifyUrl); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
navigator.clipboard.writeText(podcast.spotifyUrl); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+132
to
+135
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The catch block silently handles errors without informing the user. Consider adding user feedback (e.g., toast notification) when the Web Share API fails and fallback to clipboard is used, or when clipboard operations fail.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback
Comment on lines
+132
to
+135
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The clipboard operation lacks error handling. The
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+134
to
+136
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This clipboard operation should be wrapped in a try-catch block to handle cases where clipboard access is denied or the API is unavailable. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const handlePodcastClick = (podcast: PodcastData, event: React.MouseEvent | React.KeyboardEvent) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const target = event.target as HTMLElement; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (target.tagName === 'IFRAME' || target.closest('.podcast-embed')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -236,7 +252,10 @@ export default function Podcasts(): ReactElement { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<button className="action-btn favorite" title="Add to favorites"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
❤️ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<button className="action-btn share" title="Share podcast"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<button className="action-btn share" title="Share podcast" onClick={(e) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
e.stopPropagation(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
handleShare(podcast); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
🔗 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
The clipboard fallback in the catch block should handle potential clipboard API failures. The clipboard.writeText() method can also throw errors if clipboard access is denied or unavailable.
Copilot uses AI. Check for mistakes.