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