ClaimLink: skip blacklist check (#329)

## Issue
- It was checking the blacklist on every render.
- Finding opportunities to improve performance

## Changes
Since the final destination will be a dead end anyways, skip the blacklist check so that livestreams can render a bit faster when there lots of mentions.

The only downside is that a claim preview for a blacklisted item would now appear (vs. being a text previously)
This commit is contained in:
infinite-persistence 2021-11-19 06:46:52 -08:00 committed by GitHub
parent 328b60d021
commit 21cb405965
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 23 deletions

View file

@ -3,7 +3,6 @@ import { makeSelectClaimForUri, selectIsUriResolving } from 'redux/selectors/cla
import { doResolveUri } from 'redux/actions/claims'; import { doResolveUri } from 'redux/actions/claims';
import { doSetPlayingUri } from 'redux/actions/content'; import { doSetPlayingUri } from 'redux/actions/content';
import { punctuationMarks } from 'util/remark-lbry'; import { punctuationMarks } from 'util/remark-lbry';
import { selectBlackListedOutpoints } from 'lbryinc';
import { selectPlayingUri } from 'redux/selectors/content'; import { selectPlayingUri } from 'redux/selectors/content';
import ClaimLink from './view'; import ClaimLink from './view';
@ -26,7 +25,6 @@ const select = (state, props) => {
claim, claim,
fullUri: props.uri, fullUri: props.uri,
isResolvingUri: selectIsUriResolving(state, uri), isResolvingUri: selectIsUriResolving(state, uri),
blackListedOutpoints: selectBlackListedOutpoints(state),
playingUri: selectPlayingUri(state), playingUri: selectPlayingUri(state),
}; };
}; };

View file

@ -15,10 +15,6 @@ type Props = {
description: ?string, description: ?string,
isResolvingUri: boolean, isResolvingUri: boolean,
doResolveUri: (string) => void, doResolveUri: (string) => void,
blackListedOutpoints: Array<{
txid: string,
nout: number,
}>,
playingUri: ?PlayingUri, playingUri: ?PlayingUri,
parentCommentId?: string, parentCommentId?: string,
isMarkdownPost?: boolean, isMarkdownPost?: boolean,
@ -43,21 +39,6 @@ class ClaimLink extends React.Component<Props> {
this.resolve(this.props); this.resolve(this.props);
} }
isClaimBlackListed() {
const { claim, blackListedOutpoints } = this.props;
const signingChannel = claim && claim.signing_channel;
if (claim && blackListedOutpoints) {
let blackListed = false;
blackListed = blackListedOutpoints.some(
(outpoint) =>
(signingChannel && outpoint.txid === signingChannel.txid && outpoint.nout === signingChannel.nout) ||
(outpoint.txid === claim.txid && outpoint.nout === claim.nout)
);
return blackListed;
}
}
resolve = (props: Props) => { resolve = (props: Props) => {
const { isResolvingUri, doResolveUri, claim, uri } = props; const { isResolvingUri, doResolveUri, claim, uri } = props;
@ -79,14 +60,13 @@ class ClaimLink extends React.Component<Props> {
allowPreview, allowPreview,
} = this.props; } = this.props;
const isUnresolved = (!isResolvingUri && !claim) || !claim; const isUnresolved = (!isResolvingUri && !claim) || !claim;
const isBlacklisted = this.isClaimBlackListed();
const isPlayingInline = const isPlayingInline =
playingUri && playingUri &&
playingUri.uri === uri && playingUri.uri === uri &&
((playingUri.source === 'comment' && parentCommentId === playingUri.commentId) || ((playingUri.source === 'comment' && parentCommentId === playingUri.commentId) ||
playingUri.source === 'markdown'); playingUri.source === 'markdown');
if (isBlacklisted || isUnresolved) { if (isUnresolved) {
return <span>{children}</span>; return <span>{children}</span>;
} }