improve twitter share

This commit is contained in:
btzr-io 2021-07-23 23:50:20 -05:00 committed by jessopb
parent 37d9cbfbeb
commit d462f96834
2 changed files with 18 additions and 1 deletions

View file

@ -2065,5 +2065,6 @@
"Reset": "Reset",
"Reset to original (previous) publish date": "Reset to original (previous) publish date",
"Search for something...": "Search for something...",
"Show reply": "Show reply",
"--end--": "--end--"
}

View file

@ -14,6 +14,12 @@ import { URL, SHARE_DOMAIN_URL } from 'config';
const SHARE_DOMAIN = SHARE_DOMAIN_URL || URL;
const IOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
const SUPPORTS_SHARE_API = typeof navigator.share !== 'undefined';
const IS_ODYSEE = SHARE_DOMAIN === 'https://odysee.com';
// Twitter share
const TWITTER_LBRY = 'LBRYcom';
const TWITTER_ODYSEE = 'OdyseeTeam';
const TWITTER_INTENT_API = 'https://twitter.com/intent/tweet?';
type Props = {
claim: StreamClaim,
@ -68,6 +74,16 @@ function SocialShare(props: Props) {
);
const downloadUrl = `${generateDownloadUrl(name, claimId)}`;
// Tweet params
let tweetIntentParams = {
url: shareUrl,
via: IS_ODYSEE ? TWITTER_ODYSEE : TWITTER_LBRY,
text: title || claim.name,
hashtags: 'LBRY',
};
// Generate twitter web intent url
const tweetIntent = TWITTER_INTENT_API + new URLSearchParams(tweetIntentParams).toString();
function handleWebShareClick() {
if (navigator.share) {
navigator.share({
@ -115,7 +131,7 @@ function SocialShare(props: Props) {
iconSize={24}
icon={ICONS.TWITTER}
title={__('Share on Twitter')}
href={`https://twitter.com/intent/tweet?text=${encodedLbryURL}`}
href={tweetIntent}
/>
<Button
className="share"