diff --git a/static/app-strings.json b/static/app-strings.json index b4cc13f9e..f00d1fbc4 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -701,7 +701,11 @@ "Bid position must be a number.": "Bid position must be a number.", "Copy": "Copy", "Copy Link": "Copy Link", + "Link copied.": "Link copied.", + "Failed to copy link.": "Failed to copy link.", "Copy RSS URL": "Copy RSS URL", + "RSS URL copied.": "RSS URL copied.", + "Failed to copy RSS URL.": "Failed to copy RSS URL.", "Text copied": "Text copied", "Rewards Disabled": "Rewards Disabled", "Wallet servers are used to relay data to and from the LBRY blockchain. They also determine what content shows in trending or is blocked. %learn_more%.": "Wallet servers are used to relay data to and from the LBRY blockchain. They also determine what content shows in trending or is blocked. %learn_more%.", diff --git a/ui/component/claimMenuList/view.jsx b/ui/component/claimMenuList/view.jsx index 9463d8675..271502c47 100644 --- a/ui/component/claimMenuList/view.jsx +++ b/ui/component/claimMenuList/view.jsx @@ -44,7 +44,7 @@ type Props = { collectionName?: string, collectionId: string, isMyCollection: boolean, - doToast: ({ message: string }) => void, + doToast: ({ message: string, isError?: boolean }) => void, claimIsMine: boolean, fileInfo: FileListItem, prepareEdit: ({}, string, {}) => void, @@ -183,12 +183,23 @@ function ClaimMenuList(props: Props) { } } + function copyToClipboard(textToCopy, successMsg, failureMsg) { + navigator.clipboard + .writeText(textToCopy) + .then(() => { + doToast({ message: __(successMsg) }); + }) + .catch(() => { + doToast({ message: __(failureMsg), isError: true }); + }); + } + function handleCopyRssLink() { - navigator.clipboard.writeText(rssUrl); + copyToClipboard(rssUrl, 'RSS URL copied.', 'Failed to copy RSS URL.'); } function handleCopyLink() { - navigator.clipboard.writeText(shareUrl); + copyToClipboard(shareUrl, 'Link copied.', 'Failed to copy link.'); } function handleReportContent() {