Fix Subtraction Game link
The Subtraction Game link and copy link functionality have been fixed.
This commit is contained in:
parent
eb41d56dc0
commit
b6dddec259
2 changed files with 19 additions and 5 deletions
|
|
@ -83,6 +83,7 @@ const App = () => (
|
|||
<Route path="/themes/advanced-algorithms" element={<AdvancedAlgorithms />} />
|
||||
<Route path="/themes/data-structures" element={<DataStructures />} />
|
||||
<Route path="/themes/games" element={<Games />} />
|
||||
<Route path="/themes/games/subtraction-game" element={<SubtractionGamePage />} />
|
||||
<Route path="/themes/games/sim" element={<GameOfSimPage />} />
|
||||
<Route path="/themes/cards-math" element={<CardsMath />} />
|
||||
<Route path="/themes/puzzles" element={<Puzzles />} />
|
||||
|
|
|
|||
|
|
@ -45,7 +45,10 @@ const SocialShare: React.FC<SocialShareProps> = ({
|
|||
}, [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<SocialShareProps> = ({
|
|||
}
|
||||
|
||||
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<SocialShareProps> = ({
|
|||
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<SocialShareProps> = ({
|
|||
return;
|
||||
}
|
||||
|
||||
console.log('Using modern clipboard API');
|
||||
await navigator.clipboard.writeText(text);
|
||||
console.log('Copy successful');
|
||||
toast({
|
||||
title: "Copied!",
|
||||
description: "Link copied to clipboard",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue