From e2db26c595aea70548f2444364079b82db6156f7 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Sun, 25 Apr 2021 11:27:59 +0800 Subject: [PATCH] Fix channel links being filtered by Staked Level ## Issue Channel links were showing the "This channel isn't staking enough LBRY Credits for link previews." -- channel links shouldn't be showing previews in the first place. ## Change Moved the logic into `ClaimLink`, which is the better place to put it anyway. I think I was trying to not touch as many components as possible (i.e. not passing `allowPreview` down too many layers) in the initial implementation. This caused the `isChannel` consideration to be missed. --- ui/component/claimLink/view.jsx | 28 ++++++++++++++++++++++++---- ui/component/markdownLink/view.jsx | 18 +++++------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/ui/component/claimLink/view.jsx b/ui/component/claimLink/view.jsx index f2fe09726..f5e7ee69c 100644 --- a/ui/component/claimLink/view.jsx +++ b/ui/component/claimLink/view.jsx @@ -5,6 +5,7 @@ import EmbedPlayButton from 'component/embedPlayButton'; import Button from 'component/button'; import UriIndicator from 'component/uriIndicator'; import { INLINE_PLAYER_WRAPPER_CLASS } from 'component/fileRenderFloating/view'; +import { SIMPLE_SITE } from 'config'; type Props = { uri: string, @@ -12,7 +13,7 @@ type Props = { children: React.Node, description: ?string, isResolvingUri: boolean, - doResolveUri: string => void, + doResolveUri: (string) => void, blackListedOutpoints: Array<{ txid: string, nout: number, @@ -20,6 +21,7 @@ type Props = { playingUri: ?PlayingUri, parentCommentId?: string, isMarkdownPost?: boolean, + allowPreview: boolean, }; class ClaimLink extends React.Component { @@ -29,6 +31,7 @@ class ClaimLink extends React.Component { thumbnail: null, description: null, isResolvingUri: false, + allowPreview: false, }; componentDidMount() { @@ -46,7 +49,7 @@ class ClaimLink extends React.Component { let blackListed = false; blackListed = blackListedOutpoints.some( - outpoint => + (outpoint) => (signingChannel && outpoint.txid === signingChannel.txid && outpoint.nout === signingChannel.nout) || (outpoint.txid === claim.txid && outpoint.nout === claim.nout) ); @@ -63,7 +66,16 @@ class ClaimLink extends React.Component { }; render() { - const { uri, claim, children, isResolvingUri, playingUri, parentCommentId, isMarkdownPost } = this.props; + const { + uri, + claim, + children, + isResolvingUri, + playingUri, + parentCommentId, + isMarkdownPost, + allowPreview, + } = this.props; const isUnresolved = (!isResolvingUri && !claim) || !claim; const isBlacklisted = this.isClaimBlackListed(); const isPlayingInline = @@ -81,7 +93,7 @@ class ClaimLink extends React.Component { return isChannel ? ( - ) : ( + ) : allowPreview ? (
{
+ ) : ( +