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