lbry-desktop/ui/component/claimPreviewSubtitle/index.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

import * as PAGES from 'constants/pages';
import { connect } from 'react-redux';
2021-03-17 21:53:35 +01:00
import {
selectClaimForUri,
2021-03-17 21:53:35 +01:00
makeSelectClaimIsPending,
makeSelectClaimIsStreamPlaceholder,
} from 'redux/selectors/claims';
import { doClearPublish, doPrepareEdit } from 'redux/actions/publish';
import { push } from 'connected-react-router';
2020-01-30 23:25:15 +01:00
import ClaimPreviewSubtitle from './view';
import { doFetchSubCount, makeSelectSubCountForUri } 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 ? makeSelectSubCountForUri(props.uri)(state) : 0,
};
};
2021-03-17 21:53:35 +01:00
const perform = (dispatch) => ({
beginPublish: (name) => {
dispatch(doClearPublish());
dispatch(doPrepareEdit({ name }));
2020-07-23 19:02:07 +02:00
dispatch(push(`/$/${PAGES.UPLOAD}`));
},
fetchSubCount: (claimId) => dispatch(doFetchSubCount(claimId)),
});
2020-07-23 19:02:07 +02:00
export default connect(select, perform)(ClaimPreviewSubtitle);