import React from "react"; import { Icon } from "component/common"; import Link from "component/link"; import lbryuri from "lbryuri.js"; class UriIndicator extends React.PureComponent { componentWillMount() { this.resolve(this.props); } componentWillReceiveProps(nextProps) { this.resolve(nextProps); } resolve(props) { const { isResolvingUri, resolveUri, claim, uri } = props; if (!isResolvingUri && claim === undefined && uri) { resolveUri(uri); } } render() { const { claim, link, uri, isResolvingUri } = this.props; if (isResolvingUri && !claim) { return Validating...; } if (!claim) { return Unused; } const { channel_name: channelName, has_signature: hasSignature, signature_is_valid: signatureIsValid, value, } = claim; const channelClaimId = value && value.publisherSignature && value.publisherSignature.certificateId; if (!hasSignature || !channelName) { return Anonymous; } let icon, channelLink, modifier; if (signatureIsValid) { modifier = "valid"; channelLink = link ? lbryuri.build({ channelName, claimId: channelClaimId }, false) : false; } else { icon = "icon-times-circle"; modifier = "invalid"; } const inner = ( {channelName} {" "} {!signatureIsValid ? : ""} ); if (!channelLink) { return inner; } return ( {inner} ); } } export default UriIndicator;