lbry-desktop/ui/page/embedWrapper/index.js

66 lines
2.6 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import EmbedWrapperPage from './view';
import { selectClaimForUri, selectIsUriResolving, selectGeoRestrictionForUri } from 'redux/selectors/claims';
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
import { doResolveUri } from 'redux/actions/claims';
import { buildURI } from 'util/lbryURI';
2020-05-21 17:11:56 -04:00
import { doPlayUri } from 'redux/actions/content';
2022-03-16 11:28:59 -03:00
import { selectShouldObscurePreviewForUri } from 'redux/selectors/content';
import { selectCostInfoForUri, doFetchCostInfoForUri, selectBlackListedOutpoints } from 'lbryinc';
2022-03-15 13:47:36 -03:00
import { doCommentSocketConnect, doCommentSocketDisconnect } from 'redux/actions/websocket';
import { doFetchActiveLivestreams, doFetchChannelLiveStatus } from 'redux/actions/livestream';
import { selectIsActiveLivestreamForUri, selectActiveLivestreamInitialized } from 'redux/selectors/livestream';
2022-03-16 11:28:59 -03:00
import { getThumbnailFromClaim, isStreamPlaceholderClaim } from 'util/claim';
import { doUserSetReferrerWithUri } from 'redux/actions/user';
const select = (state, props) => {
const { match } = props;
const { params } = match;
const { claimName, claimId } = params;
2020-06-12 17:23:16 -04:00
const uri = claimName ? buildURI({ claimName, claimId }) : '';
2022-03-15 13:47:36 -03:00
const claim = selectClaimForUri(state, uri);
2022-03-16 14:35:27 -03:00
const { canonical_url: canonicalUrl, signing_channel: channelClaim, txid, nout } = claim || {};
const { claim_id: channelClaimId, canonical_url: channelUri, txid: channelTxid, channelNout } = channelClaim || {};
const haveClaim = Boolean(claim);
const nullClaim = claim === null;
2022-03-15 13:47:36 -03:00
return {
uri,
2022-03-16 14:35:27 -03:00
claimId,
haveClaim,
nullClaim,
canonicalUrl,
txid,
nout,
channelUri,
channelClaimId,
channelTxid,
channelNout,
costInfo: uri && selectCostInfoForUri(state, uri),
streamingUrl: uri && makeSelectStreamingUrlForUri(uri)(state),
isResolvingUri: uri && selectIsUriResolving(state, uri),
blackListedOutpoints: haveClaim && selectBlackListedOutpoints(state),
2022-03-15 13:47:36 -03:00
isCurrentClaimLive: canonicalUrl && selectIsActiveLivestreamForUri(state, canonicalUrl),
isLivestreamClaim: isStreamPlaceholderClaim(claim),
2022-03-16 11:28:59 -03:00
obscurePreview: selectShouldObscurePreviewForUri(state, uri),
claimThumbnail: getThumbnailFromClaim(claim),
activeLivestreamInitialized: selectActiveLivestreamInitialized(state),
geoRestriction: selectGeoRestrictionForUri(state, uri),
};
};
2022-03-15 13:47:36 -03:00
const perform = {
doResolveUri,
doPlayUri,
doFetchCostInfoForUri,
doFetchChannelLiveStatus,
doCommentSocketConnect,
doCommentSocketDisconnect,
doFetchActiveLivestreams,
setReferrer: doUserSetReferrerWithUri,
2020-01-31 14:33:40 -05:00
};
2020-04-13 19:48:11 -04:00
export default connect(select, perform)(EmbedWrapperPage);