hide comments from filtered outpoints
This commit is contained in:
parent
683132b8d1
commit
d47e59a596
1 changed files with 24 additions and 5 deletions
|
@ -3,7 +3,7 @@ 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 { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
import { selectBlackListedOutpoints } from 'lbryinc';
|
import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
|
||||||
import { selectClaimsById, isClaimNsfw, selectMyActiveClaims } from 'lbry-redux';
|
import { selectClaimsById, isClaimNsfw, selectMyActiveClaims } from 'lbry-redux';
|
||||||
|
|
||||||
const selectState = state => state.comments || {};
|
const selectState = state => state.comments || {};
|
||||||
|
@ -57,11 +57,21 @@ export const makeSelectCommentsForUri = (uri: string) =>
|
||||||
selectMyActiveClaims,
|
selectMyActiveClaims,
|
||||||
selectBlockedChannels,
|
selectBlockedChannels,
|
||||||
selectBlackListedOutpoints,
|
selectBlackListedOutpoints,
|
||||||
|
selectFilteredOutpoints,
|
||||||
makeSelectClientSetting(SETTINGS.SHOW_MATURE),
|
makeSelectClientSetting(SETTINGS.SHOW_MATURE),
|
||||||
(byClaimId, byUri, claimsById, myClaims, blockedChannels, blacklistedOutpoints, showMatureContent) => {
|
(
|
||||||
|
byClaimId,
|
||||||
|
byUri,
|
||||||
|
claimsById,
|
||||||
|
myClaims,
|
||||||
|
blockedChannels,
|
||||||
|
blacklistedOutpoints,
|
||||||
|
filteredOutpoints,
|
||||||
|
showMatureContent
|
||||||
|
) => {
|
||||||
const claimId = byUri[uri];
|
const claimId = byUri[uri];
|
||||||
const comments = byClaimId && byClaimId[claimId];
|
const comments = byClaimId && byClaimId[claimId];
|
||||||
const outpointMap = blacklistedOutpoints
|
const blacklistedMap = blacklistedOutpoints
|
||||||
? blacklistedOutpoints.reduce((acc, val) => {
|
? blacklistedOutpoints.reduce((acc, val) => {
|
||||||
const outpoint = `${val.txid}:${val.nout}`;
|
const outpoint = `${val.txid}:${val.nout}`;
|
||||||
return {
|
return {
|
||||||
|
@ -70,6 +80,15 @@ export const makeSelectCommentsForUri = (uri: string) =>
|
||||||
};
|
};
|
||||||
}, {})
|
}, {})
|
||||||
: {};
|
: {};
|
||||||
|
const filteredMap = filteredOutpoints
|
||||||
|
? filteredOutpoints.reduce((acc, val) => {
|
||||||
|
const outpoint = `${val.txid}:${val.nout}`;
|
||||||
|
return {
|
||||||
|
...acc,
|
||||||
|
[outpoint]: 1,
|
||||||
|
};
|
||||||
|
}, {})
|
||||||
|
: {};
|
||||||
|
|
||||||
return comments
|
return comments
|
||||||
? comments.filter(comment => {
|
? comments.filter(comment => {
|
||||||
|
@ -77,7 +96,7 @@ 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) {
|
if (myClaims && myClaims.size > 0) {
|
||||||
const claimIsMine = channelClaim.is_my_output || myClaims.has(channelClaim.claim_id);
|
const claimIsMine = channelClaim.is_my_output || myClaims.has(channelClaim.claim_id);
|
||||||
if (claimIsMine) {
|
if (claimIsMine) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -85,7 +104,7 @@ export const makeSelectCommentsForUri = (uri: string) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
const outpoint = `${channelClaim.txid}:${channelClaim.nout}`;
|
const outpoint = `${channelClaim.txid}:${channelClaim.nout}`;
|
||||||
if (outpointMap[outpoint]) {
|
if (blacklistedMap[outpoint] || filteredMap[outpoint]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue