// @flow import * as ICONS from 'constants/icons'; import React from 'react'; import { MenuList, MenuItem } from '@reach/menu-button'; import ChannelThumbnail from 'component/channelThumbnail'; import Icon from 'component/common/icon'; type Props = { uri: string, clearPlayingUri: () => void, authorUri: string, // full LBRY Channel URI: lbry://@channel#123... commentId: string, // sha256 digest identifying the comment commentIsMine: boolean, // if this comment was signed by an owned channel deleteComment: (string, ?string) => void, linkedComment?: any, isPinned: boolean, pinComment: (string, boolean) => Promise, blockChannel: (string) => void, fetchComments: (string) => void, handleEditComment: () => void, contentChannelPermanentUrl: any, activeChannelClaim: ?ChannelClaim, isTopLevel: boolean, commentModBlock: (string) => void, playingUri: ?PlayingUri, }; function CommentMenuList(props: Props) { const { uri, authorUri, commentIsMine, commentId, deleteComment, blockChannel, pinComment, clearPlayingUri, activeChannelClaim, contentChannelPermanentUrl, isTopLevel, isPinned, handleEditComment, fetchComments, commentModBlock, playingUri, } = props; const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl; function handlePinComment(commentId, remove) { pinComment(commentId, remove).then(() => fetchComments(uri)); } function handleDeleteComment() { if (playingUri && playingUri.source === 'comment') { clearPlayingUri(); } deleteComment(commentId, commentIsMine ? undefined : contentChannelPermanentUrl); } function handleCommentBlock() { commentModBlock(authorUri); } function handleCommentMute() { blockChannel(authorUri); } return ( {activeChannelIsCreator &&
{__('Creator tools')}
} {activeChannelIsCreator && isTopLevel && ( handlePinComment(commentId, true) : () => handlePinComment(commentId, false)} > {isPinned ? __('Unpin') : __('Pin')} )} {activeChannelClaim && (activeChannelClaim.permanent_url === authorUri || activeChannelClaim.permanent_url === contentChannelPermanentUrl) && (
{__('Remove')}
)} {commentIsMine && activeChannelClaim && activeChannelClaim.permanent_url === authorUri && ( {__('Edit')} )} {!commentIsMine && (
{__('Block')}
{activeChannelIsCreator && ( {__('Prevent this channel from interacting with you.')} )}
)} {!commentIsMine && (
{__('Mute')}
{activeChannelIsCreator && ( {__('Hide this channel for you only.')} )}
)} {activeChannelClaim && (
{__('Interacting as %channelName%', { channelName: activeChannelClaim.name })}
)}
); } export default CommentMenuList;