add message for number of hidden nsfw files
This commit is contained in:
parent
22483a5b2b
commit
72be966242
7 changed files with 88 additions and 30 deletions
|
@ -63,7 +63,7 @@ class FileCard extends React.PureComponent<Props> {
|
|||
pending,
|
||||
} = this.props;
|
||||
|
||||
const shouldHide = obscureNsfw && metadata && metadata.nsfw && !claimIsMine;
|
||||
const shouldHide = !claimIsMine && !pending && obscureNsfw && metadata && metadata.nsfw;
|
||||
if (shouldHide) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -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 = () => <div className="file-tile">{__('No results')}</div>;
|
||||
|
||||
|
@ -11,7 +12,6 @@ type Props = {
|
|||
isSearching: boolean,
|
||||
uris: ?Array<string>,
|
||||
downloadUris: ?Array<string>,
|
||||
resultCount: number,
|
||||
};
|
||||
|
||||
class FileListSearch extends React.PureComponent<Props> {
|
||||
|
@ -33,25 +33,25 @@ class FileListSearch extends React.PureComponent<Props> {
|
|||
|
||||
return (
|
||||
query && (
|
||||
<React.Fragment>
|
||||
<div className="search__results">
|
||||
<div className="search-result__row">
|
||||
<div className="file-list__header">{__('Content')}</div>
|
||||
{!isSearching &&
|
||||
(fileResults.length ? (
|
||||
<HiddenNsfwClaims uris={uris} />
|
||||
{!isSearching && fileResults.length ? (
|
||||
fileResults.map(uri => <FileTile key={uri} uri={uri} />)
|
||||
) : (
|
||||
<NoResults />
|
||||
))}
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="search-result__row">
|
||||
<div className="file-list__header">{__('Channels')}</div>
|
||||
{!isSearching &&
|
||||
(channelResults.length ? (
|
||||
{!isSearching && channelResults.length ? (
|
||||
channelResults.map(uri => <ChannelTile key={uri} uri={uri} />)
|
||||
) : (
|
||||
<NoResults />
|
||||
))}
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="search-result__row">
|
||||
|
@ -63,6 +63,7 @@ class FileListSearch extends React.PureComponent<Props> {
|
|||
)}
|
||||
</div>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -30,4 +30,7 @@ const perform = dispatch => ({
|
|||
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(FileTile);
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(FileTile);
|
||||
|
|
|
@ -64,7 +64,7 @@ class FileTile extends React.PureComponent<Props> {
|
|||
hideNoResult,
|
||||
} = this.props;
|
||||
|
||||
const shouldHide = obscureNsfw && metadata && metadata.nsfw && !claimIsMine;
|
||||
const shouldHide = !claimIsMine && obscureNsfw && metadata && metadata.nsfw;
|
||||
if (shouldHide) {
|
||||
return null;
|
||||
}
|
||||
|
|
30
src/renderer/component/hiddenNsfwClaims/index.js
Normal file
30
src/renderer/component/hiddenNsfwClaims/index.js
Normal file
|
@ -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);
|
21
src/renderer/component/hiddenNsfwClaims/view.jsx
Normal file
21
src/renderer/component/hiddenNsfwClaims/view.jsx
Normal file
|
@ -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) && (
|
||||
<div className={className || 'help'}>
|
||||
{numberOfNsfwClaims} {numberOfNsfwClaims > 1 ? __('files') : __('file')}{' '}
|
||||
{__('hidden due to your content viewing preferences.')}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
};
|
|
@ -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<Claim>,
|
||||
fetchClaims: (string, number) => void,
|
||||
fetchClaimCount: string => void,
|
||||
navigate: (string, {}) => void,
|
||||
|
@ -51,9 +52,10 @@ class ChannelPage extends React.PureComponent<Props> {
|
|||
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<Props> {
|
|||
}
|
||||
|
||||
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<Props> {
|
|||
/>
|
||||
</FormRow>
|
||||
)}
|
||||
<HiddenNsfwClaims className="card__content help" uri={uri} />
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue