Merge pull request #1760 from lbryio/nsfw-community

hide community row if nsfw content is hidden
This commit is contained in:
Sean Yesmunt 2018-07-12 19:54:34 -04:00 committed by GitHub
commit aea3816133
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 43 deletions

View file

@ -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);

View file

@ -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,8 +222,7 @@ 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={__(
@ -230,6 +231,7 @@ class CategoryList extends React.PureComponent<Props, State> {
/> />
)} )}
</div> </div>
{showScrollButtons && (
<div className="card-row__scroll-btns"> <div className="card-row__scroll-btns">
<Button <Button
className="btn--arrow" className="btn--arrow"
@ -244,21 +246,31 @@ class CategoryList extends React.PureComponent<Props, State> {
icon={icons.ARROW_RIGHT} icon={icons.ARROW_RIGHT}
/> />
</div> </div>
)}
</div> </div>
{obscureNsfw && isCommunityTopBids ? (
<div className="card__content help">
{__(
'The community top bids section is only visible if you allow mature content in the app. You can change your content viewing preferences'
)}{' '}
<Button button="link" navigate="/settings" label={__('here')} />.
</div>
) : (
<div <div
className="card-row__scrollhouse"
ref={ref => { ref={ref => {
this.rowItems = ref; this.rowItems = ref;
}} }}
className="card-row__scrollhouse"
> >
{names && names.map(name => <FileCard key={name} uri={normalizeURI(name)} />)} {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>
); );
} }

View file

@ -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 {