feat(client): improve error handling if unable to copy to clipboard

This commit is contained in:
Elian Doran 2025-05-26 20:12:38 +03:00
parent a666e26194
commit ac0f6662a6
No known key found for this signature in database

View File

@ -114,12 +114,20 @@ export function copyText(text: string) {
return;
}
let succeeded = false;
try {
if (navigator.clipboard) {
navigator.clipboard.writeText(text);
toast.showMessage(t("code_block.copy_success"));
succeeded = true;
}
} catch (e) {
succeeded = false;
}
if (succeeded) {
toast.showMessage(t("code_block.copy_success"));
} else {
toast.showError(t("code_block.copy_failed"));
}
}