lbry-desktop/ui/component/claimPreviewTile/index.js
infinite-persistence d5c964c208
Additional geoblock support (#1552)
* Remove claim from channel page when geoblock conditions hits

Ticket: 1100

* Handle geoblocked channel page

## Ticket
1100

## Issue
"If a channel is geoblocked, the entire channel page (even showing titles, etc. would be against the law)"
2022-05-24 00:15:18 -04:00

49 lines
2.1 KiB
JavaScript

import { connect } from 'react-redux';
import {
makeSelectClaimForUri,
selectIsUriResolving,
selectTitleForUri,
selectDateForUri,
selectGeoRestrictionForUri,
selectClaimIsMine,
} from 'redux/selectors/claims';
import { doFileGet } from 'redux/actions/file';
import { doResolveUri } from 'redux/actions/claims';
import { selectViewCountForUri, selectBanStateForUri } from 'lbryinc';
import { selectIsActiveLivestreamForUri, selectViewersForId } from 'redux/selectors/livestream';
import { selectShowMatureContent } from 'redux/selectors/settings';
import { isClaimNsfw, isStreamPlaceholderClaim, getThumbnailFromClaim } from 'util/claim';
import ClaimPreviewTile from './view';
import formatMediaDuration from 'util/formatMediaDuration';
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 });
const isLivestream = isStreamPlaceholderClaim(claim);
return {
claim,
mediaDuration,
date: props.uri && selectDateForUri(state, props.uri),
isResolvingUri: props.uri && selectIsUriResolving(state, props.uri),
claimIsMine: props.uri && selectClaimIsMine(state, claim),
thumbnail: getThumbnailFromClaim(claim),
title: props.uri && selectTitleForUri(state, props.uri),
banState: selectBanStateForUri(state, props.uri),
geoRestriction: selectGeoRestrictionForUri(state, props.uri),
showMature: selectShowMatureContent(state),
isMature: claim ? isClaimNsfw(claim) : false,
isLivestream,
isLivestreamActive: isLivestream && selectIsActiveLivestreamForUri(state, props.uri),
livestreamViewerCount: isLivestream && claim ? selectViewersForId(state, claim.claim_id) : undefined,
viewCount: selectViewCountForUri(state, props.uri),
};
};
const perform = (dispatch) => ({
resolveUri: (uri) => dispatch(doResolveUri(uri)),
getFile: (uri) => dispatch(doFileGet(uri, false)),
});
export default connect(select, perform)(ClaimPreviewTile);