2019-06-28 09:27:55 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import {
|
2021-10-08 03:57:48 +02:00
|
|
|
selectClaimForUri,
|
2021-11-16 05:43:28 +01:00
|
|
|
selectIsUriResolving,
|
2021-11-11 05:48:10 +01:00
|
|
|
selectClaimIsMine,
|
2019-06-28 09:27:55 +02:00
|
|
|
makeSelectClaimIsPending,
|
2020-05-07 14:22:55 +02:00
|
|
|
makeSelectReflectingClaimForUri,
|
2021-11-16 05:23:18 +01:00
|
|
|
selectTitleForUri,
|
2021-10-08 03:57:48 +02:00
|
|
|
selectDateForUri,
|
2022-05-24 06:15:18 +02:00
|
|
|
selectGeoRestrictionForUri,
|
2021-10-17 10:36:14 +02:00
|
|
|
} from 'redux/selectors/claims';
|
|
|
|
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
|
2022-01-12 20:14:12 +01:00
|
|
|
import { makeSelectCollectionIsMine } from 'redux/selectors/collections';
|
2021-10-17 10:36:14 +02:00
|
|
|
|
|
|
|
import { doResolveUri } from 'redux/actions/claims';
|
|
|
|
import { doFileGet } from 'redux/actions/file';
|
2021-10-25 16:56:31 +02:00
|
|
|
import { selectBanStateForUri } from 'lbryinc';
|
2022-04-15 13:02:51 +02:00
|
|
|
import { selectIsActiveLivestreamForUri, selectViewersForId } from 'redux/selectors/livestream';
|
2022-01-11 17:42:12 +01:00
|
|
|
import { selectLanguage, selectShowMatureContent } from 'redux/selectors/settings';
|
2020-05-21 17:38:28 +02:00
|
|
|
import { makeSelectHasVisitedUri } from 'redux/selectors/content';
|
2021-11-12 15:47:07 +01:00
|
|
|
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
|
2022-02-02 13:45:16 +01:00
|
|
|
import { isClaimNsfw, isStreamPlaceholderClaim } from 'util/claim';
|
2019-06-28 09:27:55 +02:00
|
|
|
import ClaimPreview from './view';
|
2021-07-16 08:53:38 +02:00
|
|
|
import formatMediaDuration from 'util/formatMediaDuration';
|
2022-05-04 12:24:13 +02:00
|
|
|
import { doClearContentHistoryUri } from 'redux/actions/content';
|
2019-06-28 09:27:55 +02:00
|
|
|
|
2021-07-16 08:53:38 +02:00
|
|
|
const select = (state, props) => {
|
2021-10-08 03:57:48 +02:00
|
|
|
const claim = props.uri && selectClaimForUri(state, props.uri);
|
2021-07-16 08:53:38 +02:00
|
|
|
const media = claim && claim.value && (claim.value.video || claim.value.audio);
|
|
|
|
const mediaDuration = media && media.duration && formatMediaDuration(media.duration, { screenReader: true });
|
2021-11-16 04:52:35 +01:00
|
|
|
const isLivestream = isStreamPlaceholderClaim(claim);
|
2021-07-16 08:53:38 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
claim,
|
|
|
|
mediaDuration,
|
2021-10-08 03:57:48 +02:00
|
|
|
date: props.uri && selectDateForUri(state, props.uri),
|
2021-11-16 05:23:18 +01:00
|
|
|
title: props.uri && selectTitleForUri(state, props.uri),
|
2021-07-16 08:53:38 +02:00
|
|
|
pending: props.uri && makeSelectClaimIsPending(props.uri)(state),
|
|
|
|
reflectingProgress: props.uri && makeSelectReflectingClaimForUri(props.uri)(state),
|
|
|
|
obscureNsfw: selectShowMatureContent(state) === false,
|
2021-11-11 05:48:10 +01:00
|
|
|
claimIsMine: props.uri && selectClaimIsMine(state, claim),
|
2021-11-16 05:43:28 +01:00
|
|
|
isResolvingUri: props.uri && selectIsUriResolving(state, props.uri),
|
|
|
|
isResolvingRepost: props.uri && selectIsUriResolving(state, props.repostUrl),
|
2021-11-16 02:10:03 +01:00
|
|
|
nsfw: claim ? isClaimNsfw(claim) : false,
|
2021-10-25 16:56:31 +02:00
|
|
|
banState: selectBanStateForUri(state, props.uri),
|
2022-05-24 06:15:18 +02:00
|
|
|
geoRestriction: selectGeoRestrictionForUri(state, props.uri),
|
2021-07-16 08:53:38 +02:00
|
|
|
hasVisitedUri: props.uri && makeSelectHasVisitedUri(props.uri)(state),
|
2021-11-12 15:47:07 +01:00
|
|
|
isSubscribed: props.uri && selectIsSubscribedForUri(state, props.uri),
|
2021-07-16 08:53:38 +02:00
|
|
|
streamingUrl: props.uri && makeSelectStreamingUrlForUri(props.uri)(state),
|
2021-11-16 04:52:35 +01:00
|
|
|
isLivestream,
|
|
|
|
isLivestreamActive: isLivestream && selectIsActiveLivestreamForUri(state, props.uri),
|
2022-04-15 13:02:51 +02:00
|
|
|
livestreamViewerCount: isLivestream && claim ? selectViewersForId(state, claim.claim_id) : undefined,
|
2021-07-16 08:53:38 +02:00
|
|
|
isCollectionMine: makeSelectCollectionIsMine(props.collectionId)(state),
|
2022-01-11 17:42:12 +01:00
|
|
|
lang: selectLanguage(state),
|
2021-07-16 08:53:38 +02:00
|
|
|
};
|
|
|
|
};
|
2019-06-28 09:27:55 +02:00
|
|
|
|
2021-03-03 19:50:16 +01:00
|
|
|
const perform = (dispatch) => ({
|
|
|
|
resolveUri: (uri) => dispatch(doResolveUri(uri)),
|
|
|
|
getFile: (uri) => dispatch(doFileGet(uri, false)),
|
2022-05-04 12:24:13 +02:00
|
|
|
doClearContentHistoryUri: (uri) => dispatch(doClearContentHistoryUri(uri)),
|
2019-06-28 09:27:55 +02:00
|
|
|
});
|
|
|
|
|
2020-04-01 20:43:50 +02:00
|
|
|
export default connect(select, perform)(ClaimPreview);
|