lbry-desktop/ui/component/claimPreviewSubtitle/index.js
infinite-persistence 652ec4b69b
Fix memo: makeSelectViewCountForUri, makeSelectSubCountForUri
- switch to a lighter selectClaimIdForUri
- also, these 2 don't need to memo because they are just simple accessors.
2021-11-16 08:15:24 +08:00

34 lines
1.1 KiB
JavaScript

import * as PAGES from 'constants/pages';
import { connect } from 'react-redux';
import {
selectClaimForUri,
makeSelectClaimIsPending,
makeSelectClaimIsStreamPlaceholder,
} from 'redux/selectors/claims';
import { doClearPublish, doPrepareEdit } from 'redux/actions/publish';
import { push } from 'connected-react-router';
import ClaimPreviewSubtitle from './view';
import { doFetchSubCount, selectSubCountForUri } from 'lbryinc';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
const isChannel = claim && claim.value_type === 'channel';
return {
claim,
pending: makeSelectClaimIsPending(props.uri)(state),
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
subCount: isChannel ? selectSubCountForUri(state, props.uri) : 0,
};
};
const perform = (dispatch) => ({
beginPublish: (name) => {
dispatch(doClearPublish());
dispatch(doPrepareEdit({ name }));
dispatch(push(`/$/${PAGES.UPLOAD}`));
},
fetchSubCount: (claimId) => dispatch(doFetchSubCount(claimId)),
});
export default connect(select, perform)(ClaimPreviewSubtitle);