Show smaller NSFW tag if it's my content #1585

Merged
kkorte merged 1 commit from master into master 2018-06-13 06:16:13 +02:00
2 changed files with 14 additions and 3 deletions

View file

@ -5,6 +5,7 @@ import {
makeSelectMetadataForUri, makeSelectMetadataForUri,
makeSelectFileInfoForUri, makeSelectFileInfoForUri,
makeSelectIsUriResolving, makeSelectIsUriResolving,
makeSelectClaimIsMine,
} from 'lbry-redux'; } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { selectRewardContentClaimIds } from 'redux/selectors/content'; import { selectRewardContentClaimIds } from 'redux/selectors/content';
@ -27,6 +28,7 @@ const select = (state, props) => {
return { return {
obscureNsfw: !selectShowNsfw(state), obscureNsfw: !selectShowNsfw(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
rewardedContentClaimIds: selectRewardContentClaimIds(state, props), rewardedContentClaimIds: selectRewardContentClaimIds(state, props),
...fileCardInfo, ...fileCardInfo,
pending: !!pendingPublish, pending: !!pendingPublish,
@ -38,4 +40,7 @@ const perform = dispatch => ({
resolveUri: uri => dispatch(doResolveUri(uri)), resolveUri: uri => dispatch(doResolveUri(uri)),
}); });
export default connect(select, perform)(FileCard); export default connect(
select,
perform
)(FileCard);

View file

@ -16,12 +16,17 @@ type Props = {
uri: string, uri: string,
claim: ?{ claim_id: string }, claim: ?{ claim_id: string },
fileInfo: ?{}, fileInfo: ?{},
metadata: ?{ nsfw: boolean, thumbnail: ?string }, metadata: ?{ nsfw: boolean, title: string, thumbnail: ?string },
navigate: (string, ?{}) => void, navigate: (string, ?{}) => void,
rewardedContentClaimIds: Array<string>, rewardedContentClaimIds: Array<string>,
obscureNsfw: boolean, obscureNsfw: boolean,
claimIsMine: boolean,
showPrice: boolean, showPrice: boolean,
pending?: boolean, pending?: boolean,
/* eslint-disable react/no-unused-prop-types */
resolveUri: string => void,
isResolvingUri: boolean,
/* eslint-enable react/no-unused-prop-types */
}; };
class FileCard extends React.PureComponent<Props> { class FileCard extends React.PureComponent<Props> {
@ -53,13 +58,14 @@ class FileCard extends React.PureComponent<Props> {
navigate, navigate,
rewardedContentClaimIds, rewardedContentClaimIds,
obscureNsfw, obscureNsfw,
claimIsMine,
showPrice, showPrice,
pending, pending,
} = this.props; } = this.props;
const uri = !pending ? normalizeURI(this.props.uri) : this.props.uri; const uri = !pending ? normalizeURI(this.props.uri) : this.props.uri;
const title = metadata && metadata.title ? metadata.title : uri; const title = metadata && metadata.title ? metadata.title : uri;
const thumbnail = metadata && metadata.thumbnail ? metadata.thumbnail : null; const thumbnail = metadata && metadata.thumbnail ? metadata.thumbnail : null;
const shouldObscureNsfw = obscureNsfw && metadata && metadata.nsfw; const shouldObscureNsfw = obscureNsfw && metadata && metadata.nsfw && !claimIsMine;
const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id); const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id);
const handleContextMenu = event => { const handleContextMenu = event => {
event.preventDefault(); event.preventDefault();