diff --git a/ui/redux/selectors/comments.js b/ui/redux/selectors/comments.js index c5bb16778..e0647a9f1 100644 --- a/ui/redux/selectors/comments.js +++ b/ui/redux/selectors/comments.js @@ -1,8 +1,10 @@ // @flow +import * as SETTINGS from 'constants/settings'; import { createSelector } from 'reselect'; import { selectBlockedChannels } from 'redux/selectors/blocked'; +import { makeSelectClientSetting } from 'redux/selectors/settings'; import { selectBlackListedOutpoints } from 'lbryinc'; -import { selectClaimsById } from 'lbry-redux'; +import { selectClaimsById, isClaimNsfw, selectMyActiveClaims } from 'lbry-redux'; const selectState = state => state.comments || {}; @@ -52,9 +54,11 @@ export const makeSelectCommentsForUri = (uri: string) => selectCommentsByClaimId, selectCommentsByUri, selectClaimsById, + selectMyActiveClaims, selectBlockedChannels, selectBlackListedOutpoints, - (byClaimId, byUri, claimsById, blockedChannels, blacklistedOutpoints) => { + makeSelectClientSetting(SETTINGS.SHOW_MATURE), + (byClaimId, byUri, claimsById, myClaims, blockedChannels, blacklistedOutpoints, showMatureContent) => { const claimId = byUri[uri]; const comments = byClaimId && byClaimId[claimId]; const outpointMap = blacklistedOutpoints @@ -73,13 +77,26 @@ export const makeSelectCommentsForUri = (uri: string) => // Return comment if `channelClaim` doesn't exist so the component knows to resolve the author if (channelClaim) { + if (myClaims && myClaims.length) { + const claimIsMine = channelClaim.is_my_output || myClaims.has(channelClaim.claim_id); + if (claimIsMine) { + return true; + } + } + const outpoint = `${channelClaim.txid}:${channelClaim.nout}`; if (outpointMap[outpoint]) { return false; } + + if (!showMatureContent) { + const claimIsMature = isClaimNsfw(channelClaim); + if (claimIsMature) { + return false; + } + } } - console.log('?'); return !blockedChannels.includes(comment.channel_url); }) : [];