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