lbry-desktop/ui/component/claimLink/index.js
infinite-persistence 21cb405965
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)
2021-11-19 09:46:52 -05:00

32 lines
998 B
JavaScript

import { connect } from 'react-redux';
import { makeSelectClaimForUri, selectIsUriResolving } from 'redux/selectors/claims';
import { doResolveUri } from 'redux/actions/claims';
import { doSetPlayingUri } from 'redux/actions/content';
import { punctuationMarks } from 'util/remark-lbry';
import { selectPlayingUri } from 'redux/selectors/content';
import ClaimLink from './view';
const select = (state, props) => {
let uri = props.uri;
let claim;
function getValidClaim(testUri) {
claim = makeSelectClaimForUri(testUri)(state);
if (claim === null && punctuationMarks.includes(testUri.charAt(testUri.length - 1))) {
getValidClaim(testUri.substring(0, testUri.length - 1));
} else {
uri = testUri;
}
}
getValidClaim(uri);
return {
uri,
claim,
fullUri: props.uri,
isResolvingUri: selectIsUriResolving(state, uri),
playingUri: selectPlayingUri(state),
};
};
export default connect(select, { doResolveUri, doSetPlayingUri })(ClaimLink);