diff --git a/src/renderer/component/fileCard/view.jsx b/src/renderer/component/fileCard/view.jsx index d2cda73ee..7a7e4f7d5 100644 --- a/src/renderer/component/fileCard/view.jsx +++ b/src/renderer/component/fileCard/view.jsx @@ -63,7 +63,7 @@ class FileCard extends React.PureComponent { pending, } = this.props; - const shouldHide = obscureNsfw && metadata && metadata.nsfw && !claimIsMine; + const shouldHide = !claimIsMine && !pending && obscureNsfw && metadata && metadata.nsfw; if (shouldHide) { return null; } diff --git a/src/renderer/component/fileListSearch/view.jsx b/src/renderer/component/fileListSearch/view.jsx index 248b0045e..baf812d22 100644 --- a/src/renderer/component/fileListSearch/view.jsx +++ b/src/renderer/component/fileListSearch/view.jsx @@ -1,8 +1,9 @@ // @flow -import React from 'react'; +import * as React from 'react'; +import { parseURI } from 'lbry-redux'; import FileTile from 'component/fileTile'; import ChannelTile from 'component/channelTile'; -import { parseURI } from 'lbry-redux'; +import HiddenNsfwClaims from 'component/hiddenNsfwClaims'; const NoResults = () =>
{__('No results')}
; @@ -11,7 +12,6 @@ type Props = { isSearching: boolean, uris: ?Array, downloadUris: ?Array, - resultCount: number, }; class FileListSearch extends React.PureComponent { @@ -33,36 +33,37 @@ class FileListSearch extends React.PureComponent { return ( query && ( -
-
-
{__('Content')}
- {!isSearching && - (fileResults.length ? ( + +
+
+
{__('Content')}
+ + {!isSearching && fileResults.length ? ( fileResults.map(uri => ) ) : ( - ))} -
+ )} +
-
-
{__('Channels')}
- {!isSearching && - (channelResults.length ? ( +
+
{__('Channels')}
+ {!isSearching && channelResults.length ? ( channelResults.map(uri => ) ) : ( - ))} -
+ )} +
-
-
{__('Your downloads')}
- {downloadUris && downloadUris.length ? ( - downloadUris.map(uri => ) - ) : ( - - )} +
+
{__('Your downloads')}
+ {downloadUris && downloadUris.length ? ( + downloadUris.map(uri => ) + ) : ( + + )} +
-
+ ) ); } diff --git a/src/renderer/component/fileTile/index.js b/src/renderer/component/fileTile/index.js index 17f0bf8a5..e5e242291 100644 --- a/src/renderer/component/fileTile/index.js +++ b/src/renderer/component/fileTile/index.js @@ -30,4 +30,7 @@ const perform = dispatch => ({ updatePublishForm: value => dispatch(doUpdatePublishForm(value)), }); -export default connect(select, perform)(FileTile); +export default connect( + select, + perform +)(FileTile); diff --git a/src/renderer/component/fileTile/view.jsx b/src/renderer/component/fileTile/view.jsx index 63c59e41e..60d4fc202 100644 --- a/src/renderer/component/fileTile/view.jsx +++ b/src/renderer/component/fileTile/view.jsx @@ -64,7 +64,7 @@ class FileTile extends React.PureComponent { hideNoResult, } = this.props; - const shouldHide = obscureNsfw && metadata && metadata.nsfw && !claimIsMine; + const shouldHide = !claimIsMine && obscureNsfw && metadata && metadata.nsfw; if (shouldHide) { return null; } diff --git a/src/renderer/component/hiddenNsfwClaims/index.js b/src/renderer/component/hiddenNsfwClaims/index.js new file mode 100644 index 000000000..cc951582e --- /dev/null +++ b/src/renderer/component/hiddenNsfwClaims/index.js @@ -0,0 +1,30 @@ +import { connect } from 'react-redux'; +import { makeSelectNsfwCountForChannel, makeSelectNsfwCountFromUris, parseURI } from 'lbry-redux'; +import { selectShowNsfw } from 'redux/selectors/settings'; +import HiddenNsfwClaims from './view'; + +const select = (state, props) => { + const { uri, uris } = props; + + let numberOfNsfwClaims; + if (uri) { + const { isChannel } = parseURI(uri); + numberOfNsfwClaims = isChannel + ? makeSelectNsfwCountForChannel(uri)(state) + : makeSelectNsfwCountFromUris([uri])(state); + } else if (uris) { + numberOfNsfwClaims = makeSelectNsfwCountFromUris(uris)(state); + } + + return { + numberOfNsfwClaims, + obscureNsfw: !selectShowNsfw(state), + }; +}; + +const perform = () => ({}); + +export default connect( + select, + perform +)(HiddenNsfwClaims); diff --git a/src/renderer/component/hiddenNsfwClaims/view.jsx b/src/renderer/component/hiddenNsfwClaims/view.jsx new file mode 100644 index 000000000..333473d71 --- /dev/null +++ b/src/renderer/component/hiddenNsfwClaims/view.jsx @@ -0,0 +1,21 @@ +// @flow +import React from 'react'; + +type Props = { + numberOfNsfwClaims: number, + obscureNsfw: boolean, + className: ?string, +}; + +export default (props: Props) => { + const { numberOfNsfwClaims, obscureNsfw, className } = props; + return ( + obscureNsfw && + Boolean(numberOfNsfwClaims) && ( +
+ {numberOfNsfwClaims} {numberOfNsfwClaims > 1 ? __('files') : __('file')}{' '} + {__('hidden due to your content viewing preferences.')} +
+ ) + ); +}; diff --git a/src/renderer/page/channel/view.jsx b/src/renderer/page/channel/view.jsx index da49f8e6a..949808d73 100644 --- a/src/renderer/page/channel/view.jsx +++ b/src/renderer/page/channel/view.jsx @@ -7,6 +7,7 @@ import SubscribeButton from 'component/subscribeButton'; import ViewOnWebButton from 'component/viewOnWebButton'; import Page from 'component/page'; import FileList from 'component/fileList'; +import HiddenNsfwClaims from 'component/hiddenNsfwClaims'; import type { Claim } from 'types/claim'; type Props = { @@ -16,7 +17,7 @@ type Props = { fetching: boolean, params: { page: number }, claim: Claim, - claimsInChannel: Array<{}>, + claimsInChannel: Array, fetchClaims: (string, number) => void, fetchClaimCount: string => void, navigate: (string, {}) => void, @@ -51,9 +52,10 @@ class ChannelPage extends React.PureComponent { paginate(e: SyntheticKeyboardEvent<*>, totalPages: number) { // Change page if enter was pressed, and the given page is between // the first and the last. - const pageFromInput = Number(e.target.value); + const pageFromInput = Number(e.currentTarget.value); if ( + pageFromInput && e.keyCode === 13 && !Number.isNaN(pageFromInput) && pageFromInput > 0 && @@ -64,7 +66,7 @@ class ChannelPage extends React.PureComponent { } render() { - const { fetching, claimsInChannel, claim, page, totalPages } = this.props; + const { uri, fetching, claimsInChannel, claim, page, totalPages } = this.props; const { name, permanent_url: permanentUrl, claim_id: claimId } = claim; const currentPage = parseInt((page || 1) - 1, 10); @@ -116,6 +118,7 @@ class ChannelPage extends React.PureComponent { /> )} + ); }