Merge pull request #1760 from lbryio/nsfw-community
hide community row if nsfw content is hidden
This commit is contained in:
commit
aea3816133
3 changed files with 66 additions and 43 deletions
|
@ -4,15 +4,20 @@ import {
|
||||||
makeSelectClaimsInChannelForCurrentPage,
|
makeSelectClaimsInChannelForCurrentPage,
|
||||||
makeSelectFetchingChannelClaims,
|
makeSelectFetchingChannelClaims,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
|
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||||
import CategoryList from './view';
|
import CategoryList from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
channelClaims: makeSelectClaimsInChannelForCurrentPage(props.categoryLink)(state),
|
channelClaims: makeSelectClaimsInChannelForCurrentPage(props.categoryLink)(state),
|
||||||
fetching: makeSelectFetchingChannelClaims(props.categoryLink)(state),
|
fetching: makeSelectFetchingChannelClaims(props.categoryLink)(state),
|
||||||
|
obscureNsfw: !selectShowNsfw(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
fetchChannel: channel => dispatch(doFetchClaimsByChannel(channel)),
|
fetchChannel: channel => dispatch(doFetchClaimsByChannel(channel)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(CategoryList);
|
export default connect(
|
||||||
|
select,
|
||||||
|
perform
|
||||||
|
)(CategoryList);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { normalizeURI } from 'lbry-redux';
|
import { normalizeURI } from 'lbry-redux';
|
||||||
import ToolTip from 'component/common/tooltip';
|
import ToolTip from 'component/common/tooltip';
|
||||||
import FileCard from 'component/fileCard';
|
import FileCard from 'component/fileCard';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import * as icons from 'constants/icons';
|
import * as icons from 'constants/icons';
|
||||||
import Claim from 'types/claim';
|
import type { Claim } from 'types/claim';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
category: string,
|
category: string,
|
||||||
|
@ -14,6 +14,7 @@ type Props = {
|
||||||
fetching: boolean,
|
fetching: boolean,
|
||||||
channelClaims: Array<Claim>,
|
channelClaims: Array<Claim>,
|
||||||
fetchChannel: string => void,
|
fetchChannel: string => void,
|
||||||
|
obscureNsfw: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
@ -206,11 +207,12 @@ class CategoryList extends React.PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { category, categoryLink, names, channelClaims } = this.props;
|
const { category, categoryLink, names, channelClaims, obscureNsfw } = this.props;
|
||||||
const { canScrollNext, canScrollPrevious } = this.state;
|
const { canScrollNext, canScrollPrevious } = this.state;
|
||||||
|
|
||||||
// The lint was throwing an error saying we should use <button> instead of <a>
|
const isCommunityTopBids = category.match(/^community/i);
|
||||||
// We are using buttons, needs more exploration
|
const showScrollButtons = isCommunityTopBids ? !obscureNsfw : true;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card-row">
|
<div className="card-row">
|
||||||
<div className="card-row__header">
|
<div className="card-row__header">
|
||||||
|
@ -220,45 +222,55 @@ class CategoryList extends React.PureComponent<Props, State> {
|
||||||
) : (
|
) : (
|
||||||
category
|
category
|
||||||
)}
|
)}
|
||||||
{category &&
|
{isCommunityTopBids && (
|
||||||
category.match(/^community/i) && (
|
<ToolTip
|
||||||
<ToolTip
|
label={__("What's this?")}
|
||||||
label={__("What's this?")}
|
body={__(
|
||||||
body={__(
|
'Community Content is a public space where anyone can share content with the rest of the LBRY community. Bid on the names from "one" to "ten" to put your content here!'
|
||||||
'Community Content is a public space where anyone can share content with the rest of the LBRY community. Bid on the names from "one" to "ten" to put your content here!'
|
)}
|
||||||
)}
|
/>
|
||||||
/>
|
)}
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="card-row__scroll-btns">
|
|
||||||
<Button
|
|
||||||
className="btn--arrow"
|
|
||||||
disabled={!canScrollPrevious}
|
|
||||||
onClick={this.handleScrollPrevious}
|
|
||||||
icon={icons.ARROW_LEFT}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
className="btn--arrow"
|
|
||||||
disabled={!canScrollNext}
|
|
||||||
onClick={this.handleScrollNext}
|
|
||||||
icon={icons.ARROW_RIGHT}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
{showScrollButtons && (
|
||||||
|
<div className="card-row__scroll-btns">
|
||||||
|
<Button
|
||||||
|
className="btn--arrow"
|
||||||
|
disabled={!canScrollPrevious}
|
||||||
|
onClick={this.handleScrollPrevious}
|
||||||
|
icon={icons.ARROW_LEFT}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
className="btn--arrow"
|
||||||
|
disabled={!canScrollNext}
|
||||||
|
onClick={this.handleScrollNext}
|
||||||
|
icon={icons.ARROW_RIGHT}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div
|
{obscureNsfw && isCommunityTopBids ? (
|
||||||
ref={ref => {
|
<div className="card__content help">
|
||||||
this.rowItems = ref;
|
{__(
|
||||||
}}
|
'The community top bids section is only visible if you allow mature content in the app. You can change your content viewing preferences'
|
||||||
className="card-row__scrollhouse"
|
)}{' '}
|
||||||
>
|
<Button button="link" navigate="/settings" label={__('here')} />.
|
||||||
{names && names.map(name => <FileCard key={name} uri={normalizeURI(name)} />)}
|
</div>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
className="card-row__scrollhouse"
|
||||||
|
ref={ref => {
|
||||||
|
this.rowItems = ref;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{names && names.map(name => <FileCard key={name} uri={normalizeURI(name)} />)}
|
||||||
|
|
||||||
{channelClaims && channelClaims.length
|
{channelClaims &&
|
||||||
? channelClaims.map(claim => (
|
channelClaims.length &&
|
||||||
|
channelClaims.map(claim => (
|
||||||
<FileCard key={claim.claim_id} uri={`lbry://${claim.name}#${claim.claim_id}`} />
|
<FileCard key={claim.claim_id} uri={`lbry://${claim.name}#${claim.claim_id}`} />
|
||||||
))
|
))}
|
||||||
: null}
|
</div>
|
||||||
</div>
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.card--small {
|
.card--small {
|
||||||
width: var(--card-small-width);
|
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
|
|
||||||
.card__media {
|
.card__media {
|
||||||
|
@ -273,7 +272,6 @@
|
||||||
.card-row {
|
.card-row {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-width: var(--card-small-width);
|
|
||||||
padding-top: $spacing-vertical;
|
padding-top: $spacing-vertical;
|
||||||
|
|
||||||
&:first-of-type {
|
&:first-of-type {
|
||||||
|
@ -283,6 +281,14 @@
|
||||||
&:last-of-type {
|
&:last-of-type {
|
||||||
padding-bottom: $spacing-vertical * 2/3;
|
padding-bottom: $spacing-vertical * 2/3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is only for the text that is displayed when a user has nsfw hidden
|
||||||
|
// It is not used anywhere else in the app and is needed due to the css related to
|
||||||
|
// the content that scrolls off the edge of the screen
|
||||||
|
.card__content.help {
|
||||||
|
padding: 0 $spacing-width;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-row__header {
|
.card-row__header {
|
||||||
|
|
Loading…
Add table
Reference in a new issue