// @flow import * as ICONS from 'constants/icons'; import * as MODALS from 'constants/modal_types'; import React from 'react'; import { MenuList, MenuItem } from '@reach/menu-button'; import ChannelThumbnail from 'component/channelThumbnail'; import Icon from 'component/common/icon'; import { parseURI } from 'lbry-redux'; type Props = { uri: ?string, authorUri: string, // full LBRY Channel URI: lbry://@channel#123... commentId: string, // sha256 digest identifying the comment isTopLevel: boolean, isPinned: boolean, commentIsMine: boolean, // if this comment was signed by an owned channel disableEdit?: boolean, disableRemove?: boolean, supportAmount?: any, handleEditComment: () => void, // --- select --- claim: ?Claim, claimIsMine: boolean, contentChannelPermanentUrl: any, activeChannelClaim: ?ChannelClaim, playingUri: ?PlayingUri, // --- perform --- openModal: (id: string, {}) => void, clearPlayingUri: () => void, muteChannel: (string) => void, pinComment: (string, string, boolean) => Promise, commentModAddDelegate: (string, string, ChannelClaim) => void, setQuickReply: (any) => void, }; function CommentMenuList(props: Props) { const { uri, claim, authorUri, commentIsMine, commentId, muteChannel, pinComment, clearPlayingUri, activeChannelClaim, contentChannelPermanentUrl, isTopLevel, isPinned, handleEditComment, commentModAddDelegate, playingUri, disableEdit, disableRemove, openModal, supportAmount, setQuickReply, } = props; const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl; function handlePinComment(commentId, claimId, remove) { pinComment(commentId, claimId, remove); } function handleDeleteComment() { if (playingUri && playingUri.source === 'comment') { clearPlayingUri(); } openModal(MODALS.CONFIRM_REMOVE_COMMENT, { commentId, commentIsMine, contentChannelPermanentUrl, supportAmount, setQuickReply, }); } function handleCommentBlock() { openModal(MODALS.BLOCK_CHANNEL, { contentUri: uri, commenterUri: authorUri }); } function handleCommentMute() { muteChannel(authorUri); } function assignAsModerator() { if (activeChannelClaim && authorUri) { const { channelName, channelClaimId } = parseURI(authorUri); commentModAddDelegate(channelClaimId, channelName, activeChannelClaim); } } return ( {activeChannelIsCreator &&
{__('Creator tools')}
} {activeChannelIsCreator && isTopLevel && ( handlePinComment(commentId, claim ? claim.claim_id : '', isPinned)} > {isPinned ? __('Unpin') : __('Pin')} )} {activeChannelIsCreator && (
{__('Add as moderator')}
{__('Assign this user to moderate %channel%', { channel: activeChannelClaim ? activeChannelClaim.name : __('your channel'), })}
)} {!disableRemove && activeChannelClaim && (activeChannelClaim.permanent_url === authorUri || activeChannelClaim.permanent_url === contentChannelPermanentUrl) && (
{__('Remove')}
)} {commentIsMine && activeChannelClaim && activeChannelClaim.permanent_url === authorUri && !disableEdit && ( {__('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;