mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
hide mature comments based on settings
This commit is contained in:
parent
9587812962
commit
683132b8d1
1 changed files with 20 additions and 3 deletions
|
@ -1,8 +1,10 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
import * as SETTINGS from 'constants/settings';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { selectBlockedChannels } from 'redux/selectors/blocked';
|
import { selectBlockedChannels } from 'redux/selectors/blocked';
|
||||||
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
import { selectBlackListedOutpoints } from 'lbryinc';
|
import { selectBlackListedOutpoints } from 'lbryinc';
|
||||||
import { selectClaimsById } from 'lbry-redux';
|
import { selectClaimsById, isClaimNsfw, selectMyActiveClaims } from 'lbry-redux';
|
||||||
|
|
||||||
const selectState = state => state.comments || {};
|
const selectState = state => state.comments || {};
|
||||||
|
|
||||||
|
@ -52,9 +54,11 @@ export const makeSelectCommentsForUri = (uri: string) =>
|
||||||
selectCommentsByClaimId,
|
selectCommentsByClaimId,
|
||||||
selectCommentsByUri,
|
selectCommentsByUri,
|
||||||
selectClaimsById,
|
selectClaimsById,
|
||||||
|
selectMyActiveClaims,
|
||||||
selectBlockedChannels,
|
selectBlockedChannels,
|
||||||
selectBlackListedOutpoints,
|
selectBlackListedOutpoints,
|
||||||
(byClaimId, byUri, claimsById, blockedChannels, blacklistedOutpoints) => {
|
makeSelectClientSetting(SETTINGS.SHOW_MATURE),
|
||||||
|
(byClaimId, byUri, claimsById, myClaims, blockedChannels, blacklistedOutpoints, showMatureContent) => {
|
||||||
const claimId = byUri[uri];
|
const claimId = byUri[uri];
|
||||||
const comments = byClaimId && byClaimId[claimId];
|
const comments = byClaimId && byClaimId[claimId];
|
||||||
const outpointMap = blacklistedOutpoints
|
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
|
// Return comment if `channelClaim` doesn't exist so the component knows to resolve the author
|
||||||
if (channelClaim) {
|
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}`;
|
const outpoint = `${channelClaim.txid}:${channelClaim.nout}`;
|
||||||
if (outpointMap[outpoint]) {
|
if (outpointMap[outpoint]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!showMatureContent) {
|
||||||
|
const claimIsMature = isClaimNsfw(channelClaim);
|
||||||
|
if (claimIsMature) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('?');
|
|
||||||
return !blockedChannels.includes(comment.channel_url);
|
return !blockedChannels.includes(comment.channel_url);
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
|
Loading…
Add table
Reference in a new issue