hide mature comments based on settings

This commit is contained in:
Sean Yesmunt 2020-07-15 14:50:45 -04:00
parent 9587812962
commit 683132b8d1

View file

@ -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);
})
: [];