lbry-desktop/ui/page/channel/index.js
infinite-persistence 787ebd9588
Blacklist: use existing map instead of looping (#400)
We already have a pre-calculated map, but not used except for comments.

At the expense of pre-calculating it, the subsequent queries are instantaneous compared to the loop.

We are still not perfect in term of reducing re-renders, so this helps a lot.
2021-12-01 10:24:27 -05:00

46 lines
1.8 KiB
JavaScript

import { connect } from 'react-redux';
import {
selectClaimIsMine,
selectTitleForUri,
getThumbnailFromClaim,
makeSelectCoverForUri,
selectCurrentChannelPage,
selectClaimForUri,
makeSelectClaimIsPending,
} from 'redux/selectors/claims';
import { selectMyUnpublishedCollections } from 'redux/selectors/collections';
import { selectBlacklistedOutpointMap, doFetchSubCount, selectSubCountForUri } from 'lbryinc';
import { selectYoutubeChannels } from 'redux/selectors/user';
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
import { selectModerationBlockList } from 'redux/selectors/comments';
import { selectMutedChannels } from 'redux/selectors/blocked';
import { doOpenModal } from 'redux/actions/app';
import ChannelPage from './view';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
return {
title: selectTitleForUri(state, props.uri),
thumbnail: getThumbnailFromClaim(claim),
cover: makeSelectCoverForUri(props.uri)(state),
channelIsMine: selectClaimIsMine(state, claim),
page: selectCurrentChannelPage(state),
claim,
isSubscribed: selectIsSubscribedForUri(state, props.uri),
blackListedOutpointMap: selectBlacklistedOutpointMap(state),
subCount: selectSubCountForUri(state, props.uri),
pending: makeSelectClaimIsPending(props.uri)(state),
youtubeChannels: selectYoutubeChannels(state),
blockedChannels: selectModerationBlockList(state),
mutedChannels: selectMutedChannels(state),
unpublishedCollections: selectMyUnpublishedCollections(state),
};
};
const perform = (dispatch) => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
fetchSubCount: (claimId) => dispatch(doFetchSubCount(claimId)),
});
export default connect(select, perform)(ChannelPage);