diff --git a/ui/component/livestreamComment/index.js b/ui/component/livestreamComment/index.js index a75d34717..7f58393f4 100644 --- a/ui/component/livestreamComment/index.js +++ b/ui/component/livestreamComment/index.js @@ -1,10 +1,11 @@ import { connect } from 'react-redux'; -import { selectStakedLevelForChannelUri, selectClaimForUri } from 'redux/selectors/claims'; +import { selectStakedLevelForChannelUri, selectClaimForUri, selectMyClaimIdsRaw } from 'redux/selectors/claims'; import LivestreamComment from './view'; const select = (state, props) => ({ claim: selectClaimForUri(state, props.uri), stakedLevel: selectStakedLevelForChannelUri(state, props.authorUri), + myChannelIds: selectMyClaimIdsRaw(state), }); export default connect(select)(LivestreamComment); diff --git a/ui/component/livestreamComment/view.jsx b/ui/component/livestreamComment/view.jsx index 3d9b1d175..17e42e42c 100644 --- a/ui/component/livestreamComment/view.jsx +++ b/ui/component/livestreamComment/view.jsx @@ -15,42 +15,30 @@ import OptimizedImage from 'component/optimizedImage'; import { parseSticker } from 'util/comments'; type Props = { + comment: Comment, uri: string, + // --- redux: claim: StreamClaim, - authorUri: string, - commentId: string, - message: string, - commentIsMine: boolean, stakedLevel: number, - supportAmount: number, - isModerator: boolean, - isGlobalMod: boolean, - isFiat: boolean, - isPinned: boolean, + myChannelIds: ?Array, }; function LivestreamComment(props: Props) { - const { - claim, - uri, - authorUri, - message, - commentIsMine, - commentId, - stakedLevel, - supportAmount, - isModerator, - isGlobalMod, - isFiat, - isPinned, - } = props; + const { comment, claim, uri, stakedLevel, myChannelIds } = props; + const { channel_url: authorUri, comment: message, support_amount: supportAmount } = comment; const [hasUserMention, setUserMention] = React.useState(false); + const commentIsMine = comment.channel_id && isMyComment(comment.channel_id); const commentByOwnerOfContent = claim && claim.signing_channel && claim.signing_channel.permanent_url === authorUri; - const { claimName } = parseURI(authorUri); + const { claimName } = parseURI(authorUri || ''); const stickerFromMessage = parseSticker(message); + // todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine + function isMyComment(channelId: string) { + return myChannelIds ? myChannelIds.includes(channelId) : false; + } + return (
  • 0 && (
    - +
    )} @@ -73,7 +66,7 @@ function LivestreamComment(props: Props) { 'livestream-comment__info--sticker': Boolean(stickerFromMessage), })} > - {isGlobalMod && ( + {comment.is_global_mod && ( @@ -81,7 +74,7 @@ function LivestreamComment(props: Props) { )} - {isModerator && ( + {comment.is_moderator && ( @@ -107,7 +100,7 @@ function LivestreamComment(props: Props) { {claimName} - {isPinned && ( + {comment.is_pinned && ( {__('Pinned')} @@ -139,10 +132,10 @@ function LivestreamComment(props: Props) { 0} isTopLevel disableEdit diff --git a/ui/component/livestreamComments/index.js b/ui/component/livestreamComments/index.js index c235abf4b..497750510 100644 --- a/ui/component/livestreamComments/index.js +++ b/ui/component/livestreamComments/index.js @@ -1,7 +1,7 @@ import { connect } from 'react-redux'; import { MAX_LIVESTREAM_COMMENTS } from 'constants/livestream'; import { doResolveUris } from 'redux/actions/claims'; -import { selectClaimForUri, selectMyClaimIdsRaw } from 'redux/selectors/claims'; +import { selectClaimForUri } from 'redux/selectors/claims'; import { doCommentList, doSuperChatList } from 'redux/actions/comments'; import { selectTopLevelCommentsForUri, @@ -20,7 +20,6 @@ const select = (state, props) => ({ fetchingComments: selectIsFetchingComments(state), superChats: selectSuperChatsForUri(state, props.uri), superChatsTotalAmount: selectSuperChatTotalAmountForUri(state, props.uri), - myChannelIds: selectMyClaimIdsRaw(state), }); export default connect(select, { diff --git a/ui/component/livestreamComments/view.jsx b/ui/component/livestreamComments/view.jsx index 8bb1d4a04..de4bc181a 100644 --- a/ui/component/livestreamComments/view.jsx +++ b/ui/component/livestreamComments/view.jsx @@ -23,7 +23,6 @@ type Props = { fetchingComments: boolean, doSuperChatList: (string) => void, superChats: Array, - myChannelIds: ?Array, doResolveUris: (Array, boolean) => void, }; @@ -44,7 +43,6 @@ export default function LivestreamComments(props: Props) { doCommentList, fetchingComments, doSuperChatList, - myChannelIds, superChats: superChatsByAmount, doResolveUris, } = props; @@ -180,11 +178,6 @@ export default function LivestreamComments(props: Props) { }); } - // todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine - function isMyComment(channelId: string) { - return myChannelIds ? myChannelIds.includes(channelId) : false; - } - if (!claim) { return null; } @@ -293,19 +286,7 @@ export default function LivestreamComments(props: Props) { {pinnedComment && showPinned && viewMode === VIEW_MODES.CHAT && (
    - +
    ) : (