// @flow import * as ICONS from 'constants/icons'; import React from 'react'; import Button from 'component/button'; import CopyableText from 'component/copyableText'; import EmbedTextArea from 'component/embedTextArea'; import { generateDownloadUrl } from 'util/lbrytv'; const IOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform); type Props = { claim: Claim, webShareable: boolean, referralCode: string, user: any, }; type State = { showEmbed: boolean, showExtra: boolean, }; class SocialShare extends React.PureComponent { constructor(props: Props) { super(props); this.state = { showEmbed: false, showExtra: false, }; this.input = undefined; } input: ?HTMLInputElement; render() { const { claim, referralCode, user, webShareable } = this.props; const { showEmbed, showExtra } = this.state; if (!claim) { return null; } const { canonical_url: canonicalUrl, permanent_url: permanentUrl, name, claim_id: claimId } = claim; const isChannel = claim.value_type === 'channel'; const rewardsApproved = user && user.is_reward_approved; const OPEN_URL = 'https://open.lbry.com/'; const lbryUrl = canonicalUrl ? canonicalUrl.split('lbry://')[1] : permanentUrl.split('lbry://')[1]; const lbryWebUrl = lbryUrl.replace(/#/g, ':'); const encodedLbryURL: string = `${OPEN_URL}${encodeURIComponent(lbryWebUrl)}`; const referralParam: string = referralCode && rewardsApproved ? `?r=${referralCode}` : ''; const lbryURL: string = `${OPEN_URL}${lbryWebUrl}${referralParam}`; const downloadUrl = `${OPEN_URL}${generateDownloadUrl(name, claimId)}`; return (
{showEmbed && } {showExtra && (
)}
); } } export default SocialShare;