a3398843c2
Frequently used; top in perf profile Most of the time, you already have the claim object in the current context. `selectClaimIsMineForUri` will retrieve the claim again, which is wasteful, even if it is memoized (looking up the cache still takes time). Break apart the logic and added the alternative `selectClaimIsMine` for faster lookup. Co-authored-by: infinite-persistence <inf.persistence@gmail.com>
25 lines
1 KiB
JavaScript
25 lines
1 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import { doFetchSubCount, selectSubCountForUri } from 'lbryinc';
|
|
import { makeSelectTitleForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
|
|
import { makeSelectInsufficientCreditsForUri } from 'redux/selectors/content';
|
|
import FileTitleSection from './view';
|
|
|
|
const select = (state, props) => {
|
|
const claim = makeSelectClaimForUri(props.uri)(state);
|
|
const channelClaimId = claim && claim.signing_channel ? claim.signing_channel.claim_id : undefined;
|
|
const channelUri = claim && claim.signing_channel ? claim.signing_channel.canonical_url : undefined;
|
|
const subCount = channelUri && selectSubCountForUri(state, channelUri);
|
|
|
|
return {
|
|
isInsufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
|
|
title: makeSelectTitleForUri(props.uri)(state),
|
|
channelClaimId,
|
|
subCount,
|
|
};
|
|
};
|
|
|
|
const perform = (dispatch) => ({
|
|
fetchSubCount: (claimId) => dispatch(doFetchSubCount(claimId)),
|
|
});
|
|
|
|
export default connect(select, perform)(FileTitleSection);
|