2020-01-20 17:47:03 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import {
|
|
|
|
doResolveUri,
|
|
|
|
makeSelectClaimForUri,
|
|
|
|
makeSelectIsUriResolving,
|
|
|
|
makeSelectThumbnailForUri,
|
|
|
|
makeSelectTitleForUri,
|
|
|
|
doFileGet,
|
|
|
|
makeSelectChannelForClaimUri,
|
2020-02-13 22:25:14 +01:00
|
|
|
makeSelectClaimIsNsfw,
|
2021-03-30 01:05:18 +02:00
|
|
|
makeSelectClaimIsStreamPlaceholder,
|
2020-01-20 17:47:03 +01:00
|
|
|
} from 'lbry-redux';
|
2021-03-03 19:50:16 +01:00
|
|
|
import { selectMutedChannels } from 'redux/selectors/blocked';
|
2020-01-20 17:47:03 +01:00
|
|
|
import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
|
2020-02-13 22:25:14 +01:00
|
|
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
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 });
|
|
|
|
|
|
|
|
return {
|
|
|
|
claim,
|
|
|
|
mediaDuration,
|
|
|
|
channel: props.uri && makeSelectChannelForClaimUri(props.uri)(state),
|
|
|
|
isResolvingUri: props.uri && makeSelectIsUriResolving(props.uri)(state),
|
|
|
|
thumbnail: props.uri && makeSelectThumbnailForUri(props.uri)(state),
|
|
|
|
title: props.uri && makeSelectTitleForUri(props.uri)(state),
|
|
|
|
blackListedOutpoints: selectBlackListedOutpoints(state),
|
|
|
|
filteredOutpoints: selectFilteredOutpoints(state),
|
|
|
|
blockedChannelUris: selectMutedChannels(state),
|
|
|
|
showMature: selectShowMatureContent(state),
|
|
|
|
isMature: makeSelectClaimIsNsfw(props.uri)(state),
|
|
|
|
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
|
|
|
};
|
|
|
|
};
|
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);
|