From 741fbddfa2ae397e222111316ccafcfe7b2e5dc3 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Thu, 29 Apr 2021 01:35:03 +0800 Subject: [PATCH 1/3] Fix ability to delete own comments in livestream ## Issue 5832: can't remove own comments in live stream mode (if you have multiple channels?) Looks like it was just missing `commentIsMine` for the new component. --- ui/component/livestreamComments/index.js | 3 ++- ui/component/livestreamComments/view.jsx | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/component/livestreamComments/index.js b/ui/component/livestreamComments/index.js index c71f6e35d..071e9aa87 100644 --- a/ui/component/livestreamComments/index.js +++ b/ui/component/livestreamComments/index.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import { makeSelectClaimForUri } from 'lbry-redux'; +import { makeSelectClaimForUri, selectMyChannelClaims } from 'lbry-redux'; import { doCommentSocketConnect, doCommentSocketDisconnect } from 'redux/actions/websocket'; import { doCommentList, doSuperChatList } from 'redux/actions/comments'; import { @@ -16,6 +16,7 @@ const select = (state, props) => ({ fetchingComments: selectIsFetchingComments(state), superChats: makeSelectSuperChatsForUri(props.uri)(state), superChatsTotalAmount: makeSelectSuperChatTotalAmountForUri(props.uri)(state), + myChannels: selectMyChannelClaims(state), }); export default connect(select, { diff --git a/ui/component/livestreamComments/view.jsx b/ui/component/livestreamComments/view.jsx index c442a87c1..27b99a5b9 100644 --- a/ui/component/livestreamComments/view.jsx +++ b/ui/component/livestreamComments/view.jsx @@ -23,6 +23,7 @@ type Props = { doSuperChatList: (string) => void, superChats: Array, superChatsTotalAmount: number, + myChannels: ?Array, }; const VIEW_MODE_CHAT = 'view_chat'; @@ -41,6 +42,7 @@ export default function LivestreamComments(props: Props) { doSuperChatList, superChats, superChatsTotalAmount, + myChannels, } = props; const commentsRef = React.createRef(); const hasScrolledComments = React.useRef(); @@ -50,6 +52,18 @@ export default function LivestreamComments(props: Props) { const commentsLength = comments && comments.length; const commentsToDisplay = viewMode === VIEW_MODE_CHAT ? comments : superChats; + // todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine + function isMyComment(channelId: string) { + if (myChannels != null && channelId != null) { + for (let i = 0; i < myChannels.length; i++) { + if (myChannels[i].claim_id === channelId) { + return true; + } + } + } + return false; + } + React.useEffect(() => { if (claimId) { doCommentList(uri); @@ -177,6 +191,7 @@ export default function LivestreamComments(props: Props) { commentId={comment.comment_id} message={comment.comment} supportAmount={comment.support_amount} + commentIsMine={comment.channel_id && isMyComment(comment.channel_id)} /> ))} -- 2.45.2 From f5aceeeb4da1c8cf84f0e59075dce9746d121211 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Thu, 29 Apr 2021 01:39:02 +0800 Subject: [PATCH 2/3] Disable editing livestream comments It doesn't do anything at the moment, anyways. --- ui/component/commentMenuList/view.jsx | 4 +++- ui/component/livestreamComment/view.jsx | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/component/commentMenuList/view.jsx b/ui/component/commentMenuList/view.jsx index 7d7150c6c..5e676530b 100644 --- a/ui/component/commentMenuList/view.jsx +++ b/ui/component/commentMenuList/view.jsx @@ -23,6 +23,7 @@ type Props = { isTopLevel: boolean, commentModBlock: (string) => void, playingUri: ?PlayingUri, + disableEdit?: boolean, }; function CommentMenuList(props: Props) { @@ -43,6 +44,7 @@ function CommentMenuList(props: Props) { fetchComments, commentModBlock, playingUri, + disableEdit, } = props; const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl; @@ -92,7 +94,7 @@ function CommentMenuList(props: Props) { )} - {commentIsMine && activeChannelClaim && activeChannelClaim.permanent_url === authorUri && ( + {commentIsMine && activeChannelClaim && activeChannelClaim.permanent_url === authorUri && !disableEdit && ( {__('Edit')} diff --git a/ui/component/livestreamComment/view.jsx b/ui/component/livestreamComment/view.jsx index 26380dde7..0d0d83fd2 100644 --- a/ui/component/livestreamComment/view.jsx +++ b/ui/component/livestreamComment/view.jsx @@ -68,7 +68,13 @@ function Comment(props: Props) { icon={ICONS.MORE_VERTICAL} /> - + -- 2.45.2 From 455f65303f7fb48d772363eadd3d5370789bd36e Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Thu, 29 Apr 2021 03:32:13 +0800 Subject: [PATCH 3/3] Disable deleting hyperchats The "total tipped" will get deducted when hyperchats are deleted, which doesn't make sense (doesn't reflect actual total that the creator received). --- ui/component/commentMenuList/view.jsx | 5 ++++- ui/component/livestreamComment/view.jsx | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/component/commentMenuList/view.jsx b/ui/component/commentMenuList/view.jsx index 5e676530b..ce279085c 100644 --- a/ui/component/commentMenuList/view.jsx +++ b/ui/component/commentMenuList/view.jsx @@ -24,6 +24,7 @@ type Props = { commentModBlock: (string) => void, playingUri: ?PlayingUri, disableEdit?: boolean, + disableRemove?: boolean, }; function CommentMenuList(props: Props) { @@ -45,6 +46,7 @@ function CommentMenuList(props: Props) { commentModBlock, playingUri, disableEdit, + disableRemove, } = props; const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl; @@ -83,7 +85,8 @@ function CommentMenuList(props: Props) { )} - {activeChannelClaim && + {!disableRemove && + activeChannelClaim && (activeChannelClaim.permanent_url === authorUri || activeChannelClaim.permanent_url === contentChannelPermanentUrl) && ( diff --git a/ui/component/livestreamComment/view.jsx b/ui/component/livestreamComment/view.jsx index 0d0d83fd2..975a623ad 100644 --- a/ui/component/livestreamComment/view.jsx +++ b/ui/component/livestreamComment/view.jsx @@ -74,6 +74,7 @@ function Comment(props: Props) { authorUri={authorUri} commentIsMine={commentIsMine} disableEdit + disableRemove={supportAmount > 0} /> -- 2.45.2