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,
|
pending,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const shouldHide = obscureNsfw && metadata && metadata.nsfw && !claimIsMine;
|
const shouldHide = !claimIsMine && !pending && obscureNsfw && metadata && metadata.nsfw;
|
||||||
if (shouldHide) {
|
if (shouldHide) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
|
import { parseURI } from 'lbry-redux';
|
||||||
import FileTile from 'component/fileTile';
|
import FileTile from 'component/fileTile';
|
||||||
import ChannelTile from 'component/channelTile';
|
import ChannelTile from 'component/channelTile';
|
||||||
import { parseURI } from 'lbry-redux';
|
import HiddenNsfwClaims from 'component/hiddenNsfwClaims';
|
||||||
|
|
||||||
const NoResults = () => <div className="file-tile">{__('No results')}</div>;
|
const NoResults = () => <div className="file-tile">{__('No results')}</div>;
|
||||||
|
|
||||||
|
@ -11,7 +12,6 @@ type Props = {
|
||||||
isSearching: boolean,
|
isSearching: boolean,
|
||||||
uris: ?Array<string>,
|
uris: ?Array<string>,
|
||||||
downloadUris: ?Array<string>,
|
downloadUris: ?Array<string>,
|
||||||
resultCount: number,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FileListSearch extends React.PureComponent<Props> {
|
class FileListSearch extends React.PureComponent<Props> {
|
||||||
|
@ -33,25 +33,25 @@ class FileListSearch extends React.PureComponent<Props> {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
query && (
|
query && (
|
||||||
|
<React.Fragment>
|
||||||
<div className="search__results">
|
<div className="search__results">
|
||||||
<div className="search-result__row">
|
<div className="search-result__row">
|
||||||
<div className="file-list__header">{__('Content')}</div>
|
<div className="file-list__header">{__('Content')}</div>
|
||||||
{!isSearching &&
|
<HiddenNsfwClaims uris={uris} />
|
||||||
(fileResults.length ? (
|
{!isSearching && fileResults.length ? (
|
||||||
fileResults.map(uri => <FileTile key={uri} uri={uri} />)
|
fileResults.map(uri => <FileTile key={uri} uri={uri} />)
|
||||||
) : (
|
) : (
|
||||||
<NoResults />
|
<NoResults />
|
||||||
))}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="search-result__row">
|
<div className="search-result__row">
|
||||||
<div className="file-list__header">{__('Channels')}</div>
|
<div className="file-list__header">{__('Channels')}</div>
|
||||||
{!isSearching &&
|
{!isSearching && channelResults.length ? (
|
||||||
(channelResults.length ? (
|
|
||||||
channelResults.map(uri => <ChannelTile key={uri} uri={uri} />)
|
channelResults.map(uri => <ChannelTile key={uri} uri={uri} />)
|
||||||
) : (
|
) : (
|
||||||
<NoResults />
|
<NoResults />
|
||||||
))}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="search-result__row">
|
<div className="search-result__row">
|
||||||
|
@ -63,6 +63,7 @@ class FileListSearch extends React.PureComponent<Props> {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,7 @@ const perform = dispatch => ({
|
||||||
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
|
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,
|
hideNoResult,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const shouldHide = obscureNsfw && metadata && metadata.nsfw && !claimIsMine;
|
const shouldHide = !claimIsMine && obscureNsfw && metadata && metadata.nsfw;
|
||||||
if (shouldHide) {
|
if (shouldHide) {
|
||||||
return null;
|
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 ViewOnWebButton from 'component/viewOnWebButton';
|
||||||
import Page from 'component/page';
|
import Page from 'component/page';
|
||||||
import FileList from 'component/fileList';
|
import FileList from 'component/fileList';
|
||||||
|
import HiddenNsfwClaims from 'component/hiddenNsfwClaims';
|
||||||
import type { Claim } from 'types/claim';
|
import type { Claim } from 'types/claim';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -16,7 +17,7 @@ type Props = {
|
||||||
fetching: boolean,
|
fetching: boolean,
|
||||||
params: { page: number },
|
params: { page: number },
|
||||||
claim: Claim,
|
claim: Claim,
|
||||||
claimsInChannel: Array<{}>,
|
claimsInChannel: Array<Claim>,
|
||||||
fetchClaims: (string, number) => void,
|
fetchClaims: (string, number) => void,
|
||||||
fetchClaimCount: string => void,
|
fetchClaimCount: string => void,
|
||||||
navigate: (string, {}) => void,
|
navigate: (string, {}) => void,
|
||||||
|
@ -51,9 +52,10 @@ class ChannelPage extends React.PureComponent<Props> {
|
||||||
paginate(e: SyntheticKeyboardEvent<*>, totalPages: number) {
|
paginate(e: SyntheticKeyboardEvent<*>, totalPages: number) {
|
||||||
// Change page if enter was pressed, and the given page is between
|
// Change page if enter was pressed, and the given page is between
|
||||||
// the first and the last.
|
// the first and the last.
|
||||||
const pageFromInput = Number(e.target.value);
|
const pageFromInput = Number(e.currentTarget.value);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
pageFromInput &&
|
||||||
e.keyCode === 13 &&
|
e.keyCode === 13 &&
|
||||||
!Number.isNaN(pageFromInput) &&
|
!Number.isNaN(pageFromInput) &&
|
||||||
pageFromInput > 0 &&
|
pageFromInput > 0 &&
|
||||||
|
@ -64,7 +66,7 @@ class ChannelPage extends React.PureComponent<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
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 { name, permanent_url: permanentUrl, claim_id: claimId } = claim;
|
||||||
const currentPage = parseInt((page || 1) - 1, 10);
|
const currentPage = parseInt((page || 1) - 1, 10);
|
||||||
|
|
||||||
|
@ -116,6 +118,7 @@ class ChannelPage extends React.PureComponent<Props> {
|
||||||
/>
|
/>
|
||||||
</FormRow>
|
</FormRow>
|
||||||
)}
|
)}
|
||||||
|
<HiddenNsfwClaims className="card__content help" uri={uri} />
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue