2019-12-30 20:54:53 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import EmbedWrapperPage from './view';
|
2022-05-09 16:47:17 +02:00
|
|
|
import * as PAGES from 'constants/pages';
|
|
|
|
import {
|
|
|
|
selectClaimForUri,
|
|
|
|
selectIsUriResolving,
|
|
|
|
selectGeoRestrictionForUri,
|
2022-05-19 07:10:37 +02:00
|
|
|
selectLatestClaimForUri,
|
2022-05-09 16:47:17 +02:00
|
|
|
} from 'redux/selectors/claims';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
|
2022-05-09 16:47:17 +02:00
|
|
|
import { doResolveUri, doFetchLatestClaimForChannel } from 'redux/actions/claims';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { buildURI } from 'util/lbryURI';
|
2020-05-21 23:11:56 +02:00
|
|
|
import { doPlayUri } from 'redux/actions/content';
|
2022-03-16 15:28:59 +01:00
|
|
|
import { selectShouldObscurePreviewForUri } from 'redux/selectors/content';
|
2021-11-19 03:40:01 +01:00
|
|
|
import { selectCostInfoForUri, doFetchCostInfoForUri, selectBlackListedOutpoints } from 'lbryinc';
|
2022-03-15 17:47:36 +01:00
|
|
|
import { doCommentSocketConnect, doCommentSocketDisconnect } from 'redux/actions/websocket';
|
|
|
|
import { doFetchActiveLivestreams, doFetchChannelLiveStatus } from 'redux/actions/livestream';
|
2022-05-09 16:47:17 +02:00
|
|
|
import {
|
|
|
|
selectIsActiveLivestreamForUri,
|
|
|
|
selectActiveLivestreamInitialized,
|
|
|
|
selectActiveLiveClaimForChannel,
|
|
|
|
} from 'redux/selectors/livestream';
|
2022-03-16 15:28:59 +01:00
|
|
|
import { getThumbnailFromClaim, isStreamPlaceholderClaim } from 'util/claim';
|
2022-03-22 19:13:19 +01:00
|
|
|
import { doUserSetReferrerWithUri } from 'redux/actions/user';
|
2019-12-30 20:54:53 +01:00
|
|
|
|
|
|
|
const select = (state, props) => {
|
2022-05-09 16:47:17 +02:00
|
|
|
const { search } = state.router.location;
|
|
|
|
const { match } = props || {};
|
|
|
|
|
|
|
|
let uri = props.uri;
|
|
|
|
let claimId;
|
|
|
|
if (match) {
|
|
|
|
const { params } = match;
|
|
|
|
const { claimName } = params;
|
|
|
|
claimId = params.claimId;
|
|
|
|
uri = claimName ? buildURI({ claimName, claimId }) : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
const urlParams = new URLSearchParams(search);
|
|
|
|
const featureParam = urlParams.get('feature');
|
|
|
|
const isNewestPath = featureParam === PAGES.LIVE_NOW || featureParam === PAGES.LATEST;
|
2022-03-15 17:47:36 +01:00
|
|
|
|
|
|
|
const claim = selectClaimForUri(state, uri);
|
2022-03-16 18:35:27 +01:00
|
|
|
const { canonical_url: canonicalUrl, signing_channel: channelClaim, txid, nout } = claim || {};
|
2022-05-09 16:47:17 +02:00
|
|
|
if (isNewestPath) claimId = claim?.claim_id;
|
2022-03-16 18:35:27 +01:00
|
|
|
|
|
|
|
const { claim_id: channelClaimId, canonical_url: channelUri, txid: channelTxid, channelNout } = channelClaim || {};
|
|
|
|
const haveClaim = Boolean(claim);
|
|
|
|
const nullClaim = claim === null;
|
2022-03-15 17:47:36 +01:00
|
|
|
|
2022-05-09 16:47:17 +02:00
|
|
|
const latestContentClaim =
|
|
|
|
featureParam === PAGES.LIVE_NOW
|
|
|
|
? selectActiveLiveClaimForChannel(state, claimId)
|
2022-05-19 07:10:37 +02:00
|
|
|
: selectLatestClaimForUri(state, canonicalUrl);
|
2022-05-09 16:47:17 +02:00
|
|
|
const latestClaimUrl = latestContentClaim && latestContentClaim.canonical_url;
|
|
|
|
if (latestClaimUrl) uri = latestClaimUrl;
|
|
|
|
|
2019-12-30 20:54:53 +01:00
|
|
|
return {
|
|
|
|
uri,
|
2022-03-16 18:35:27 +01:00
|
|
|
claimId,
|
|
|
|
haveClaim,
|
|
|
|
nullClaim,
|
|
|
|
canonicalUrl,
|
|
|
|
txid,
|
|
|
|
nout,
|
|
|
|
channelUri,
|
|
|
|
channelClaimId,
|
|
|
|
channelTxid,
|
|
|
|
channelNout,
|
2022-05-09 16:47:17 +02:00
|
|
|
latestClaimUrl,
|
|
|
|
isNewestPath,
|
2022-03-16 18:35:27 +01:00
|
|
|
costInfo: uri && selectCostInfoForUri(state, uri),
|
|
|
|
streamingUrl: uri && makeSelectStreamingUrlForUri(uri)(state),
|
|
|
|
isResolvingUri: uri && selectIsUriResolving(state, uri),
|
|
|
|
blackListedOutpoints: haveClaim && selectBlackListedOutpoints(state),
|
2022-05-09 16:47:17 +02:00
|
|
|
isCurrentClaimLive: selectIsActiveLivestreamForUri(state, isNewestPath ? latestClaimUrl : canonicalUrl),
|
2022-03-15 17:47:36 +01:00
|
|
|
isLivestreamClaim: isStreamPlaceholderClaim(claim),
|
2022-03-16 15:28:59 +01:00
|
|
|
obscurePreview: selectShouldObscurePreviewForUri(state, uri),
|
|
|
|
claimThumbnail: getThumbnailFromClaim(claim),
|
2022-03-16 16:30:02 +01:00
|
|
|
activeLivestreamInitialized: selectActiveLivestreamInitialized(state),
|
|
|
|
geoRestriction: selectGeoRestrictionForUri(state, uri),
|
2019-12-30 20:54:53 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-03-15 17:47:36 +01:00
|
|
|
const perform = {
|
|
|
|
doResolveUri,
|
|
|
|
doPlayUri,
|
|
|
|
doFetchCostInfoForUri,
|
|
|
|
doFetchChannelLiveStatus,
|
|
|
|
doCommentSocketConnect,
|
|
|
|
doCommentSocketDisconnect,
|
|
|
|
doFetchActiveLivestreams,
|
2022-03-22 19:13:19 +01:00
|
|
|
setReferrer: doUserSetReferrerWithUri,
|
2022-05-09 16:47:17 +02:00
|
|
|
fetchLatestClaimForChannel: doFetchLatestClaimForChannel,
|
2020-01-31 20:33:40 +01:00
|
|
|
};
|
2019-12-30 20:54:53 +01:00
|
|
|
|
2020-04-14 01:48:11 +02:00
|
|
|
export default connect(select, perform)(EmbedWrapperPage);
|