6b2427768c
- and some changes to activeLivestream redux since it would return undefined if fetching and no claim, so now it returns null when no activeLivestream is found
75 lines
2.8 KiB
JavaScript
75 lines
2.8 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import { withRouter } from 'react-router';
|
|
import {
|
|
selectClaimForUri,
|
|
selectIsUriResolving,
|
|
selectClaimIsMine,
|
|
makeSelectClaimIsPending,
|
|
selectGeoRestrictionForUri,
|
|
selectLatestClaimByUri,
|
|
} from 'redux/selectors/claims';
|
|
import {
|
|
makeSelectCollectionForId,
|
|
makeSelectUrlsForCollectionId,
|
|
makeSelectIsResolvingCollectionForId,
|
|
} from 'redux/selectors/collections';
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
|
import { doResolveUri, doFetchLatestClaimForChannel } from 'redux/actions/claims';
|
|
import { doBeginPublish } from 'redux/actions/publish';
|
|
import { doOpenModal } from 'redux/actions/app';
|
|
import { doFetchItemsInCollection } from 'redux/actions/collections';
|
|
import { isStreamPlaceholderClaim } from 'util/claim';
|
|
import * as COLLECTIONS_CONSTS from 'constants/collections';
|
|
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
|
|
import { selectBlacklistedOutpointMap } from 'lbryinc';
|
|
import { selectActiveLiveClaimForChannel } from 'redux/selectors/livestream';
|
|
import { doFetchChannelLiveStatus } from 'redux/actions/livestream';
|
|
import ShowPage from './view';
|
|
|
|
const select = (state, props) => {
|
|
const { uri, location, liveContentPath } = props;
|
|
const { search } = location;
|
|
|
|
const urlParams = new URLSearchParams(search);
|
|
|
|
const claim = selectClaimForUri(state, uri);
|
|
const collectionId =
|
|
urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID) ||
|
|
(claim && claim.value_type === 'collection' && claim.claim_id) ||
|
|
null;
|
|
|
|
const { canonical_url: canonicalUrl, claim_id: claimId } = claim || {};
|
|
const latestContentClaim = liveContentPath
|
|
? selectActiveLiveClaimForChannel(state, claimId)
|
|
: selectLatestClaimByUri(state, canonicalUrl);
|
|
const latestClaimUrl = latestContentClaim && latestContentClaim.canonical_url;
|
|
|
|
return {
|
|
uri,
|
|
claim,
|
|
latestClaimUrl,
|
|
isResolvingUri: selectIsUriResolving(state, uri),
|
|
blackListedOutpointMap: selectBlacklistedOutpointMap(state),
|
|
isSubscribed: selectIsSubscribedForUri(state, uri),
|
|
claimIsMine: selectClaimIsMine(state, claim),
|
|
claimIsPending: makeSelectClaimIsPending(uri)(state),
|
|
isLivestream: isStreamPlaceholderClaim(claim),
|
|
collection: makeSelectCollectionForId(collectionId)(state),
|
|
collectionId,
|
|
collectionUrls: makeSelectUrlsForCollectionId(collectionId)(state),
|
|
isResolvingCollection: makeSelectIsResolvingCollectionForId(collectionId)(state),
|
|
isAuthenticated: selectUserVerifiedEmail(state),
|
|
geoRestriction: selectGeoRestrictionForUri(state, uri),
|
|
};
|
|
};
|
|
|
|
const perform = {
|
|
doResolveUri,
|
|
doBeginPublish,
|
|
doFetchItemsInCollection,
|
|
doOpenModal,
|
|
fetchLatestClaimForChannel: doFetchLatestClaimForChannel,
|
|
fetchChannelLiveStatus: doFetchChannelLiveStatus,
|
|
};
|
|
|
|
export default withRouter(connect(select, perform)(ShowPage));
|