diff --git a/ui/component/claimAuthor/index.js b/ui/component/claimAuthor/index.js index 736bff290..9a6e1d5d6 100644 --- a/ui/component/claimAuthor/index.js +++ b/ui/component/claimAuthor/index.js @@ -1,9 +1,13 @@ import { connect } from 'react-redux'; -import { makeSelectChannelForClaimUri } from 'redux/selectors/claims'; +import { selectChannelForClaimUri } from 'redux/selectors/claims'; import ClaimAuthor from './view'; -const select = (state, props) => ({ - channelUri: makeSelectChannelForClaimUri(props.uri)(state), -}); +const select = (state, props) => { + const { uri } = props; + + return { + channelUri: selectChannelForClaimUri(state, uri), + }; +}; export default connect(select)(ClaimAuthor); diff --git a/ui/component/claimAuthor/view.jsx b/ui/component/claimAuthor/view.jsx index c8a6fd292..adec2b8d9 100644 --- a/ui/component/claimAuthor/view.jsx +++ b/ui/component/claimAuthor/view.jsx @@ -3,12 +3,13 @@ import * as React from 'react'; import ClaimPreview from 'component/claimPreview'; type Props = { - channelUri: string, hideActions?: boolean, channelSubCount?: number, + // redux + channelUri: string, }; -function ClaimAuthor(props: Props) { +export default function ClaimAuthor(props: Props) { const { channelUri, hideActions, channelSubCount } = props; return channelUri ? ( @@ -21,8 +22,6 @@ function ClaimAuthor(props: Props) { channelSubCount={channelSubCount} /> ) : ( -
{__('Anonymous')}
+ {__('Anonymous')} ); } - -export default ClaimAuthor; diff --git a/ui/redux/selectors/claims.js b/ui/redux/selectors/claims.js index b16a7574e..a40a1f0a3 100644 --- a/ui/redux/selectors/claims.js +++ b/ui/redux/selectors/claims.js @@ -576,6 +576,24 @@ export const selectClaimIsNsfwForUri = createCachedSelector( } )((state, uri) => String(uri)); +export const selectChannelForClaimUri = createCachedSelector( + (state, uri, includePrefix) => includePrefix, + selectClaimForUri, + (includePrefix?: boolean, claim: Claim) => { + if (!claim || !claim.signing_channel || !claim.is_channel_signature_valid) { + return null; + } + + const { canonical_url: canonicalUrl, permanent_url: permanentUrl } = claim.signing_channel; + + if (canonicalUrl) { + return includePrefix ? canonicalUrl : canonicalUrl.slice('lbry://'.length); + } else { + return includePrefix ? permanentUrl : permanentUrl.slice('lbry://'.length); + } + } +)((state, uri) => String(uri)); + // Returns the associated channel uri for a given claim uri // accepts a regular claim uri lbry://something // returns the channel uri that created this claim lbry://@channel