2020-01-30 16:01:23 -05:00
|
|
|
import * as PAGES from 'constants/pages';
|
|
|
|
import { connect } from 'react-redux';
|
2022-02-02 09:45:16 -03:00
|
|
|
import { selectClaimForUri, makeSelectClaimIsPending } from 'redux/selectors/claims';
|
2022-02-26 22:55:49 +08:00
|
|
|
import { selectLanguage } from 'redux/selectors/settings';
|
2021-10-17 16:36:14 +08:00
|
|
|
import { doClearPublish, doPrepareEdit } from 'redux/actions/publish';
|
2020-01-30 16:01:23 -05:00
|
|
|
import { push } from 'connected-react-router';
|
2020-01-30 17:25:15 -05:00
|
|
|
import ClaimPreviewSubtitle from './view';
|
2021-11-15 22:08:23 +08:00
|
|
|
import { doFetchSubCount, selectSubCountForUri } from 'lbryinc';
|
2022-02-02 09:45:16 -03:00
|
|
|
import { isStreamPlaceholderClaim } from 'util/claim';
|
2020-01-30 16:01:23 -05:00
|
|
|
|
2021-10-28 11:39:30 +08:00
|
|
|
const select = (state, props) => {
|
|
|
|
const claim = selectClaimForUri(state, props.uri);
|
|
|
|
const isChannel = claim && claim.value_type === 'channel';
|
2021-12-16 15:59:13 -06:00
|
|
|
const isLivestream = isStreamPlaceholderClaim(claim);
|
2021-10-28 11:39:30 +08:00
|
|
|
return {
|
|
|
|
claim,
|
|
|
|
pending: makeSelectClaimIsPending(props.uri)(state),
|
2021-12-16 15:59:13 -06:00
|
|
|
isLivestream,
|
2022-01-19 06:04:01 -08:00
|
|
|
subCount: isChannel ? selectSubCountForUri(state, claim.repost_url ? claim.canonical_url : props.uri) : 0,
|
2022-02-26 22:55:49 +08:00
|
|
|
lang: selectLanguage(state),
|
2021-10-28 11:39:30 +08:00
|
|
|
};
|
|
|
|
};
|
2020-01-30 16:01:23 -05:00
|
|
|
|
2021-03-17 16:53:35 -04:00
|
|
|
const perform = (dispatch) => ({
|
|
|
|
beginPublish: (name) => {
|
2020-01-30 16:01:23 -05:00
|
|
|
dispatch(doClearPublish());
|
|
|
|
dispatch(doPrepareEdit({ name }));
|
2020-07-23 13:02:07 -04:00
|
|
|
dispatch(push(`/$/${PAGES.UPLOAD}`));
|
2020-01-30 16:01:23 -05:00
|
|
|
},
|
2021-10-16 14:12:09 -04:00
|
|
|
fetchSubCount: (claimId) => dispatch(doFetchSubCount(claimId)),
|
2020-01-30 16:01:23 -05:00
|
|
|
});
|
|
|
|
|
2020-07-23 13:02:07 -04:00
|
|
|
export default connect(select, perform)(ClaimPreviewSubtitle);
|