Merge pull request #245 from immich-power-tools/april-fixes

fix: copy button in share assets fix
This commit is contained in:
Varun Raj Manoharan authored and GitHub committed 2026-04-06 19:43:02 +05:30
commit 1047a1b9d8
1 file changed
+17 -3
+17 -3
View File
@@ -40,13 +40,27 @@ export default function ShareAssetsTrigger({ filters, buttonProps }: ShareAssets
});
}
const handleCopy = () => {
if (generatedLink) {
navigator.clipboard.writeText(generatedLink);
const handleCopy = async () => {
if (!generatedLink) return;
try {
if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(generatedLink);
} else {
const textArea = document.createElement('textarea');
textArea.value = generatedLink;
textArea.style.position = 'fixed';
textArea.style.left = '-9999px';
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
}
setCopied(true);
setTimeout(() => {
setCopied(false);
}, 2000);
} catch {
setErrorMessage('Failed to copy link');
}
}