2020-01-20 11:47:03 -05:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import {
|
|
|
|
makeSelectClaimForUri,
|
2021-11-16 12:43:28 +08:00
|
|
|
selectIsUriResolving,
|
2021-11-16 12:23:18 +08:00
|
|
|
selectTitleForUri,
|
2021-10-08 09:57:48 +08:00
|
|
|
selectDateForUri,
|
2022-05-24 12:15:18 +08:00
|
|
|
selectGeoRestrictionForUri,
|
|
|
|
selectClaimIsMine,
|
2021-10-17 16:36:14 +08:00
|
|
|
} from 'redux/selectors/claims';
|
|
|
|
import { doFileGet } from 'redux/actions/file';
|
|
|
|
import { doResolveUri } from 'redux/actions/claims';
|
2021-11-15 22:08:23 +08:00
|
|
|
import { selectViewCountForUri, selectBanStateForUri } from 'lbryinc';
|
2022-04-15 19:02:51 +08:00
|
|
|
import { selectIsActiveLivestreamForUri, selectViewersForId } from 'redux/selectors/livestream';
|
2020-02-13 16:25:14 -05:00
|
|
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
2022-03-15 13:28:55 -03:00
|
|
|
import { isClaimNsfw, isStreamPlaceholderClaim, getThumbnailFromClaim } from 'util/claim';
|
2020-01-20 11:47:03 -05:00
|
|
|
import ClaimPreviewTile from './view';
|
2021-07-15 18:12:11 -05:00
|
|
|
import formatMediaDuration from 'util/formatMediaDuration';
|
2020-01-20 11:47:03 -05:00
|
|
|
|
2021-07-15 18:12:11 -05:00
|
|
|
const select = (state, props) => {
|
|
|
|
const claim = props.uri && makeSelectClaimForUri(props.uri)(state);
|
|
|
|
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-15 18:12:11 -05:00
|
|
|
|
|
|
|
return {
|
|
|
|
claim,
|
|
|
|
mediaDuration,
|
2021-10-08 09:57:48 +08:00
|
|
|
date: props.uri && selectDateForUri(state, props.uri),
|
2021-11-16 12:43:28 +08:00
|
|
|
isResolvingUri: props.uri && selectIsUriResolving(state, props.uri),
|
2022-05-24 12:15:18 +08:00
|
|
|
claimIsMine: props.uri && selectClaimIsMine(state, claim),
|
2021-11-12 23:59:11 +08:00
|
|
|
thumbnail: getThumbnailFromClaim(claim),
|
2021-11-16 12:23:18 +08:00
|
|
|
title: props.uri && selectTitleForUri(state, props.uri),
|
2021-10-25 22:56:31 +08:00
|
|
|
banState: selectBanStateForUri(state, props.uri),
|
2022-05-24 12:15:18 +08:00
|
|
|
geoRestriction: selectGeoRestrictionForUri(state, props.uri),
|
2021-07-15 18:12:11 -05:00
|
|
|
showMature: selectShowMatureContent(state),
|
2021-11-16 09:10:03 +08:00
|
|
|
isMature: claim ? isClaimNsfw(claim) : false,
|
2021-11-16 11:52:35 +08:00
|
|
|
isLivestream,
|
|
|
|
isLivestreamActive: isLivestream && selectIsActiveLivestreamForUri(state, props.uri),
|
2022-04-15 19:02:51 +08:00
|
|
|
livestreamViewerCount: isLivestream && claim ? selectViewersForId(state, claim.claim_id) : undefined,
|
2021-11-15 22:08:23 +08:00
|
|
|
viewCount: selectViewCountForUri(state, props.uri),
|
2021-07-15 18:12:11 -05:00
|
|
|
};
|
|
|
|
};
|
2020-01-20 11:47:03 -05:00
|
|
|
|
2021-03-03 13:50:16 -05:00
|
|
|
const perform = (dispatch) => ({
|
|
|
|
resolveUri: (uri) => dispatch(doResolveUri(uri)),
|
|
|
|
getFile: (uri) => dispatch(doFileGet(uri, false)),
|
2020-01-20 11:47:03 -05:00
|
|
|
});
|
|
|
|
|
2020-07-15 09:50:08 -04:00
|
|
|
export default connect(select, perform)(ClaimPreviewTile);
|