From ad20e355cf38c682943f0574b55f266e7f0f060a Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 27 Oct 2020 12:24:31 -0400 Subject: [PATCH] creator only like reactions --- .env.defaults | 1 + config.js | 3 ++- ui/component/comment/view.jsx | 2 +- ui/component/commentReactions/index.js | 3 +++ ui/component/commentReactions/view.jsx | 35 ++++++++++++++++++++---- ui/component/commentsList/view.jsx | 10 ++++++- ui/component/common/icon-custom.jsx | 37 ++++++++++++++++++++++++++ ui/constants/icons.js | 1 + ui/constants/reactions.js | 1 + ui/scss/component/_comments.scss | 21 ++++++++++----- 10 files changed, 100 insertions(+), 14 deletions(-) diff --git a/.env.defaults b/.env.defaults index 1a81c5b68..975646bac 100644 --- a/.env.defaults +++ b/.env.defaults @@ -26,6 +26,7 @@ YRBL_HAPPY_IMG_URL=https://cdn.lbryplayer.xyz/api/v3/streams/free/yrbl-happy/7aa YRBL_SAD_IMG_URL=https://cdn.lbryplayer.xyz/api/v3/streams/free/yrbl-sad/c2d9649633d974e5ffb503925e1f17d951f1bd0f/f262dd ENABLE_COMMENT_REACTIONS=false ENABLE_FILE_REACTIONS=false +ENABLE_CREATOR_REACTIONS=false # OG OG_TITLE_SUFFIX=| lbry.tv diff --git a/config.js b/config.js index 1b0d7b399..59121e9ae 100644 --- a/config.js +++ b/config.js @@ -31,13 +31,14 @@ const config = { UNSYNCED_SETTINGS: process.env.UNSYNCED_SETTINGS, ENABLE_COMMENT_REACTIONS: process.env.ENABLE_COMMENT_REACTIONS === 'true', ENABLE_FILE_REACTIONS: process.env.ENABLE_FILE_REACTIONS === 'true', + ENABLE_CREATOR_REACTIONS: process.env.ENABLE_CREATOR_REACTIONS === 'true', SIMPLE_SITE: process.env.SIMPLE_SITE === 'true', SHOW_ADS: process.env.SHOW_ADS === 'true', PINNED_URI_1: process.env.PINNED_URI_1, PINNED_LABEL_1: process.env.PINNED_LABEL_1, PINNED_URI_2: process.env.PINNED_URI_2, PINNED_LABEL_2: process.env.PINNED_LABEL_2, - KNOWN_APP_DOMAINS: process.env.KNOWN_APP_DOMAINS + KNOWN_APP_DOMAINS: process.env.KNOWN_APP_DOMAINS, }; config.URL_LOCAL = `http://localhost:${config.WEB_SERVER_PORT}`; diff --git a/ui/component/comment/view.jsx b/ui/component/comment/view.jsx index f3a385388..952c9104f 100644 --- a/ui/component/comment/view.jsx +++ b/ui/component/comment/view.jsx @@ -315,7 +315,7 @@ function Comment(props: Props) { icon={ICONS.REPLY} /> )} - {ENABLE_COMMENT_REACTIONS && } + {ENABLE_COMMENT_REACTIONS && } {isReplying && ( diff --git a/ui/component/commentReactions/index.js b/ui/component/commentReactions/index.js index b37b13caa..e45b7a0fd 100644 --- a/ui/component/commentReactions/index.js +++ b/ui/component/commentReactions/index.js @@ -1,5 +1,6 @@ import { connect } from 'react-redux'; import Comment from './view'; +import { makeSelectClaimIsMine, makeSelectClaimForUri } from 'lbry-redux'; import { makeSelectMyReactionsForComment, makeSelectOthersReactionsForComment, @@ -8,6 +9,8 @@ import { import { doCommentReact } from 'redux/actions/comments'; const select = (state, props) => ({ + claim: makeSelectClaimForUri(props.uri)(state), + claimIsMine: makeSelectClaimIsMine(props.uri)(state), myReacts: makeSelectMyReactionsForComment(props.commentId)(state), othersReacts: makeSelectOthersReactionsForComment(props.commentId)(state), activeChannel: selectCommentChannel(state), diff --git a/ui/component/commentReactions/view.jsx b/ui/component/commentReactions/view.jsx index 644c5524b..d70e22da3 100644 --- a/ui/component/commentReactions/view.jsx +++ b/ui/component/commentReactions/view.jsx @@ -1,10 +1,11 @@ // @flow +import { ENABLE_CREATOR_REACTIONS } from 'config'; import * as ICONS from 'constants/icons'; import * as REACTION_TYPES from 'constants/reactions'; import React from 'react'; import classnames from 'classnames'; import Button from 'component/button'; -import usePersistedState from 'effects/use-persisted-state'; +import ChannelThumbnail from 'component/channelThumbnail'; type Props = { myReacts: Array, @@ -12,11 +13,15 @@ type Props = { react: (string, string) => void, commentId: string, pendingCommentReacts: Array, + claimIsMine: boolean, + activeChannel: string, + claim: ?ChannelClaim, }; export default function CommentReactions(props: Props) { - const { myReacts, othersReacts, commentId, react } = props; - const [activeChannel] = usePersistedState('comment-channel'); + const { myReacts, othersReacts, commentId, react, claimIsMine, claim, activeChannel } = props; + const canCreatorReact = claimIsMine && claim && claim.name === activeChannel; + const authorUri = claim && claim.value_type === 'channel' ? claim.canonical_url : ''; const getCountForReact = type => { let count = 0; @@ -29,6 +34,8 @@ export default function CommentReactions(props: Props) { return count; }; + const creatorLiked = getCountForReact(REACTION_TYPES.CREATOR_LIKE) > 0; + return ( <>