Skip to content

Commit

Permalink
Update utils.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Yidadaa authored Apr 7, 2023
1 parent 0acb877 commit 905bf41
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function trimTopic(topic: string) {
export async function copyToClipboard(text: string) {
try {
await navigator.clipboard.writeText(text);
showToast(Locale.Copy.Success);
} catch (error) {
const textArea = document.createElement("textarea");
textArea.value = text;
Expand All @@ -17,11 +18,11 @@ export async function copyToClipboard(text: string) {
textArea.select();
try {
document.execCommand("copy");
showToast(Locale.Copy.Success);
} catch (error) {
showToast(Locale.Copy.Failed);
}
} finally {
showToast(Locale.Copy.Success);
document.body.removeChild(textArea);
}
}

Expand Down

1 comment on commit 905bf41

@vercel
Copy link

@vercel vercel bot commented on 905bf41 Apr 7, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.