diff --git a/src/App.tsx b/src/App.tsx index 7003d3b..d4c3ea0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -83,6 +83,7 @@ const App = () => ( } /> } /> } /> + } /> } /> } /> } /> diff --git a/src/components/SocialShare.tsx b/src/components/SocialShare.tsx index c332c23..258d595 100644 --- a/src/components/SocialShare.tsx +++ b/src/components/SocialShare.tsx @@ -45,7 +45,10 @@ const SocialShare: React.FC = ({ }, [shareData.url, isOpen, toast]); const copyToClipboard = async (text: string) => { + console.log('Copy to clipboard called with text:', text); + if (!rateLimiter.isAllowed('clipboard', 10, 60000)) { + console.log('Rate limit exceeded for clipboard'); toast({ title: "Too many attempts", description: "Please wait before copying again", @@ -55,8 +58,11 @@ const SocialShare: React.FC = ({ } try { + console.log('Attempting to copy to clipboard...'); + // Check if clipboard API is available if (!navigator.clipboard) { + console.log('Clipboard API not available, using fallback'); // Fallback for older browsers or insecure contexts const textArea = document.createElement('textarea'); textArea.value = text; @@ -68,11 +74,16 @@ const SocialShare: React.FC = ({ textArea.select(); try { - document.execCommand('copy'); - toast({ - title: "Copied!", - description: "Link copied to clipboard", - }); + const success = document.execCommand('copy'); + console.log('Fallback copy result:', success); + if (success) { + toast({ + title: "Copied!", + description: "Link copied to clipboard", + }); + } else { + throw new Error('Copy command failed'); + } } catch (err) { console.error('Fallback copy failed:', err); toast({ @@ -86,7 +97,9 @@ const SocialShare: React.FC = ({ return; } + console.log('Using modern clipboard API'); await navigator.clipboard.writeText(text); + console.log('Copy successful'); toast({ title: "Copied!", description: "Link copied to clipboard",