Add toast feedback for RSS and Link copy action.

6369
This commit is contained in:
infinite-persistence 2021-07-09 16:01:28 +08:00
parent 1f16736e5a
commit da8000303b
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 18 additions and 3 deletions

View file

@ -701,7 +701,11 @@
"Bid position must be a number.": "Bid position must be a number.", "Bid position must be a number.": "Bid position must be a number.",
"Copy": "Copy", "Copy": "Copy",
"Copy Link": "Copy Link", "Copy Link": "Copy Link",
"Link copied.": "Link copied.",
"Failed to copy link.": "Failed to copy link.",
"Copy RSS URL": "Copy RSS URL", "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", "Text copied": "Text copied",
"Rewards Disabled": "Rewards Disabled", "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%.", "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%.",

View file

@ -44,7 +44,7 @@ type Props = {
collectionName?: string, collectionName?: string,
collectionId: string, collectionId: string,
isMyCollection: boolean, isMyCollection: boolean,
doToast: ({ message: string }) => void, doToast: ({ message: string, isError?: boolean }) => void,
claimIsMine: boolean, claimIsMine: boolean,
fileInfo: FileListItem, fileInfo: FileListItem,
prepareEdit: ({}, string, {}) => void, 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() { function handleCopyRssLink() {
navigator.clipboard.writeText(rssUrl); copyToClipboard(rssUrl, 'RSS URL copied.', 'Failed to copy RSS URL.');
} }
function handleCopyLink() { function handleCopyLink() {
navigator.clipboard.writeText(shareUrl); copyToClipboard(shareUrl, 'Link copied.', 'Failed to copy link.');
} }
function handleReportContent() { function handleReportContent() {