add option to hide anonymous content

This commit is contained in:
zxawry 2019-10-08 17:25:33 +01:00 committed by Sean Yesmunt
parent e83ccc77e2
commit a1dfc54c3d
8 changed files with 26 additions and 5 deletions

View file

@ -15,7 +15,7 @@ import {
doPrepareEdit,
} from 'lbry-redux';
import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
import { selectShowMatureContent } from 'redux/selectors/settings';
import { selectShowMatureContent, selectShowAnonymousContent } from 'redux/selectors/settings';
import { makeSelectHasVisitedUri } from 'redux/selectors/content';
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
import { push } from 'connected-react-router';
@ -26,6 +26,7 @@ const select = (state, props) => ({
pending: props.uri && makeSelectClaimIsPending(props.uri)(state),
claim: props.uri && makeSelectClaimForUri(props.uri)(state),
obscureNsfw: !selectShowMatureContent(state),
hideAnonymous: !selectShowAnonymousContent(state),
claimIsMine: props.uri && makeSelectClaimIsMine(props.uri)(state),
isResolvingUri: props.uri && makeSelectIsUriResolving(props.uri)(state),
thumbnail: props.uri && makeSelectThumbnailForUri(props.uri)(state),

View file

@ -22,6 +22,7 @@ type Props = {
uri: string,
claim: ?Claim,
obscureNsfw: boolean,
hideAnonymous: boolean,
showUserBlocked: boolean,
claimIsMine: boolean,
pending?: boolean,
@ -54,6 +55,7 @@ type Props = {
const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
const {
obscureNsfw,
hideAnonymous,
claimIsMine,
pending,
history,
@ -99,8 +101,9 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
const isChannel = isValid ? parseURI(uri).isChannel : false;
const includeChannelTooltip = type !== 'inline' && type !== 'tooltip' && !isChannel;
const signingChannel = claim && claim.signing_channel;
let shouldHide =
placeholder !== 'loading' && ((abandoned && !showPublishLink) || (!claimIsMine && obscureNsfw && nsfw));
const isAnonymous = !isChannel && !signingChannel;
const blocked = !claimIsMine && ((obscureNsfw && nsfw) || (hideAnonymous && isAnonymous));
let shouldHide = placeholder !== 'loading' && ((abandoned && !showPublishLink) || (blocked && !showUserBlocked));
// This will be replaced once blocking is done at the wallet server level
if (claim && !shouldHide && blackListedOutpoints) {
@ -125,7 +128,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
}
// block channel claims if we can't control for them in claim search
// e.g. fetchRecommendedSubscriptions
if (claim && isChannel && !shouldHide && !showUserBlocked && blockedChannelUris.length && isChannel) {
if (claim && isChannel && !shouldHide && !showUserBlocked && blockedChannelUris.length) {
shouldHide = blockedChannelUris.some(blockedUri => blockedUri === claim.permanent_url);
}

View file

@ -6,6 +6,7 @@ export const EMAIL_COLLECTION_ACKNOWLEDGED = 'email_collection_acknowledged';
export const INVITE_ACKNOWLEDGED = 'invite_acknowledged';
export const LANGUAGE = 'language';
export const SHOW_MATURE = 'show_mature';
export const SHOW_ANONYMOUS = 'show_anonymous';
export const SHOW_UNAVAILABLE = 'show_unavailable';
export const INSTANT_PURCHASE_ENABLED = 'instant_purchase_enabled';
export const INSTANT_PURCHASE_MAX = 'instant_purchase_max';

View file

@ -10,6 +10,7 @@ import SettingsPage from './view';
const select = state => ({
daemonSettings: selectDaemonSettings(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state),
showAnonymous: makeSelectClientSetting(SETTINGS.SHOW_ANONYMOUS)(state),
instantPurchaseEnabled: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state),
instantPurchaseMax: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state),
currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state),

View file

@ -46,6 +46,7 @@ type Props = {
clearCache: () => Promise<any>,
daemonSettings: DaemonSettings,
showNsfw: boolean,
showAnonymous: boolean,
instantPurchaseEnabled: boolean,
instantPurchaseMax: Price,
currentTheme: string,
@ -190,6 +191,7 @@ class SettingsPage extends React.PureComponent<Props, State> {
const {
daemonSettings,
showNsfw,
showAnonymous,
instantPurchaseEnabled,
instantPurchaseMax,
currentTheme,
@ -383,6 +385,17 @@ class SettingsPage extends React.PureComponent<Props, State> {
)}
/>
<FormField
type="checkbox"
name="show_anonymous"
onChange={() => setClientSetting(SETTINGS.SHOW_ANONYMOUS, !showAnonymous)}
checked={showAnonymous}
label={__('Show anonymous content')}
helper={__(
'You can opt for displaying contents published anonymously, i.e. contents published without a channel identity.'
)}
/>
<FormField
type="checkbox"
name="show_nsfw"

View file

@ -36,6 +36,7 @@ const defaultState = {
// Content
[SETTINGS.SHOW_MATURE]: false,
[SETTINGS.SHOW_ANONYMOUS]: true,
[SETTINGS.AUTOPLAY]: true,
[SETTINGS.FLOATING_PLAYER]: true,
[SETTINGS.AUTO_DOWNLOAD]: true,

View file

@ -26,6 +26,7 @@ export const makeSelectClientSetting = setting =>
// refactor me
export const selectShowMatureContent = makeSelectClientSetting(SETTINGS.SHOW_MATURE);
export const selectShowAnonymousContent = makeSelectClientSetting(SETTINGS.SHOW_ANONYMOUS);
export const selectTheme = makeSelectClientSetting(SETTINGS.THEME);
export const selectAutomaticDarkModeEnabled = makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED);

View file

@ -805,4 +805,4 @@
"(Only available on the desktop app.)": "(Only available on the desktop app.)",
"If we have your email address, we will send you notifications related to new content. You may configure these emails from the Help page.": "If we have your email address, we will send you notifications related to new content. You may configure these emails from the Help page.",
"Light": "Light"
}
}