Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/pages/podcasts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Comment on lines +130 to +133
Copy link

Copilot AI Sep 23, 2025

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.

} else {
navigator.clipboard.writeText(podcast.spotifyUrl);
Comment on lines +132 to +135
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The 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
navigator.clipboard.writeText(podcast.spotifyUrl);
}
} else {
navigator.clipboard.writeText(podcast.spotifyUrl);
try {
await navigator.clipboard.writeText(podcast.spotifyUrl);
alert('Sharing failed. Link copied to clipboard instead.');
} catch (clipboardErr) {
alert('Sharing failed and copying to clipboard also failed.');
}
}
} else {
try {
await navigator.clipboard.writeText(podcast.spotifyUrl);
alert('Link copied to clipboard.');
} catch (clipboardErr) {
alert('Copying to clipboard failed.');
}

Copilot uses AI. Check for mistakes.

Comment on lines +132 to +135
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

The clipboard operation lacks error handling. The writeText method can fail (e.g., when clipboard permissions are denied) and should be wrapped in a try-catch block with appropriate user feedback.

Suggested change
navigator.clipboard.writeText(podcast.spotifyUrl);
}
} else {
navigator.clipboard.writeText(podcast.spotifyUrl);
try {
await navigator.clipboard.writeText(podcast.spotifyUrl);
alert('Podcast link copied to clipboard!');
} catch (clipboardErr) {
alert('Failed to copy podcast link to clipboard.');
}
}
} else {
try {
await navigator.clipboard.writeText(podcast.spotifyUrl);
alert('Podcast link copied to clipboard!');
} catch (clipboardErr) {
alert('Failed to copy podcast link to clipboard.');
}

Copilot uses AI. Check for mistakes.

}
Comment on lines +134 to +136
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The 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.

};

const handlePodcastClick = (podcast: PodcastData, event: React.MouseEvent | React.KeyboardEvent) => {
const target = event.target as HTMLElement;
if (target.tagName === 'IFRAME' || target.closest('.podcast-embed')) {
Expand Down Expand Up @@ -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>
Expand Down
Loading