// @flow import type { Claim } from 'types/claim'; import * as ICONS from 'constants/icons'; import React from 'react'; import Button from 'component/button'; import CopyableText from 'component/copyableText'; import ToolTip from 'component/common/tooltip'; type Props = { claim: Claim, onDone: () => void, speechShareable: boolean, isChannel: boolean, }; class SocialShare extends React.PureComponent { static defaultProps = { isChannel: false, }; constructor(props: Props) { super(props); this.input = undefined; } input: ?HTMLInputElement; render() { const { claim, isChannel } = this.props; const { claim_id: claimId, name: claimName, channel_name: channelName, value } = claim; const { speechShareable, onDone } = this.props; const channelClaimId = value && value.publisherSignature && value.publisherSignature.certificateId; const speechPrefix = 'https://spee.ch/'; const lbryPrefix = 'https://open.lbry.io/'; let speechURL; let lbryURL; if (isChannel) { // For channel claims, the channel name (@something) is in `claim.name` speechURL = `${speechPrefix}${claimName}:${claimId}`; lbryURL = `${lbryPrefix}${claimName}#${claimId}`; } else { // If it's for a regular claim, check if it has an associated channel speechURL = channelName && channelClaimId ? `${speechPrefix}${channelName}:${channelClaimId}/${claimName}` : `${speechPrefix}${claimId}/${claimName}`; lbryURL = channelName && channelClaimId ? `${lbryPrefix}${channelName}#${channelClaimId}/${claimName}` : `${lbryPrefix}${claimName}#${claimId}`; } return (
{speechShareable && (
)}
); } } export default SocialShare;