From 9cfec1ce744b23854ad9bbd2b58ce8c1d53be072 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Wed, 15 Jul 2020 12:15:00 -0400 Subject: [PATCH] hide comments from blocked channels --- ui/redux/selectors/comments.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ui/redux/selectors/comments.js b/ui/redux/selectors/comments.js index 269882bb8..e498b89e9 100644 --- a/ui/redux/selectors/comments.js +++ b/ui/redux/selectors/comments.js @@ -1,5 +1,6 @@ // @flow import { createSelector } from 'reselect'; +import { selectBlockedChannels } from 'redux/selectors/blocked'; const selectState = state => state.comments || {}; @@ -45,10 +46,16 @@ export const selectCommentsByUri = createSelector(selectState, state => { }); export const makeSelectCommentsForUri = (uri: string) => - createSelector(selectCommentsByClaimId, selectCommentsByUri, (byClaimId, byUri) => { - const claimId = byUri[uri]; - return byClaimId && byClaimId[claimId]; - }); + createSelector( + selectCommentsByClaimId, + selectCommentsByUri, + selectBlockedChannels, + (byClaimId, byUri, blockedChannels) => { + const claimId = byUri[uri]; + const comments = byClaimId && byClaimId[claimId]; + return comments ? comments.filter(comment => !blockedChannels.includes(comment.channel_url)) : []; + } + ); // todo: allow SDK to retrieve user comments through comment_list // todo: implement selectors for selecting comments owned by user