From 00ba192b7e8e900c3f8d1fe645b82b01be4f14b8 Mon Sep 17 00:00:00 2001 From: miko Date: Tue, 22 Oct 2024 09:32:50 +0300 Subject: [PATCH] Disable personal blocks on moderated channels --- ui/redux/selectors/comments.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ui/redux/selectors/comments.js b/ui/redux/selectors/comments.js index a48ad159a9..ea943a91b7 100644 --- a/ui/redux/selectors/comments.js +++ b/ui/redux/selectors/comments.js @@ -173,6 +173,7 @@ const filterCommentsDepOnList = { showMatureContent: selectShowMatureContent, geoBlockList: selectGeoBlockLists, locale: selectUserLocale, + delegatorsById: selectModerationDelegatorsById, }; const filterCommentsPropKeys = Object.keys(filterCommentsDepOnList); @@ -300,8 +301,26 @@ const filterComments = (comments: Array, claimId?: string, filterInputs showMatureContent, geoBlockList, locale, + delegatorsById, } = filterProps; + const contentClaim = claimsById[claimId]; + const contentCreatorClaimId = contentClaim?.signing_channel?.claim_id; + let amDelegatedMod = false; + + for (const delegatorData of Object.values(delegatorsById)) { + if (!(delegatorData && typeof delegatorData === 'object' && 'delegators' in delegatorData)) { + continue; + } + for (const delegatorId of Object.values(delegatorData.delegators)) { + if (delegatorId === contentCreatorClaimId) { + amDelegatedMod = true; + break; + } + } + if (amDelegatedMod) break; + } + return comments ? comments.filter((comment) => { if (!comment) { @@ -339,7 +358,7 @@ const filterComments = (comments: Array, claimId?: string, filterInputs if (claimId) { const claimIdIsMine = myClaimIds && myClaimIds.size > 0 && myClaimIds.includes(claimId); - if (!claimIdIsMine) { + if (!claimIdIsMine && !amDelegatedMod) { if (personalBlockList.includes(comment.channel_url)) { return false; }