// @flow import 'scss/component/_livestream-comment.scss'; import { getStickerUrl } from 'util/comments'; import { Menu, MenuButton } from '@reach/menu-button'; import { parseURI } from 'util/lbryURI'; import * as ICONS from 'constants/icons'; import Button from 'component/button'; import ChannelThumbnail from 'component/channelThumbnail'; import classnames from 'classnames'; import CommentBadge from 'component/common/comment-badge'; import CommentMenuList from 'component/commentMenuList'; import CreditAmount from 'component/common/credit-amount'; import DateTime from 'component/dateTime'; import Empty from 'component/common/empty'; import Icon from 'component/common/icon'; import MarkdownPreview from 'component/common/markdown-preview'; import OptimizedImage from 'component/optimizedImage'; import React from 'react'; type Props = { comment: Comment, forceUpdate?: any, uri: string, // --- redux: claim: StreamClaim, myChannelIds: ?Array, stakedLevel: number, isMobile?: boolean, handleDismissPin?: () => void, restoreScrollPos?: () => void, }; export default function LivestreamComment(props: Props) { const { comment, forceUpdate, uri, claim, myChannelIds, stakedLevel, isMobile, handleDismissPin, restoreScrollPos, } = props; const { channel_url: authorUri, comment_id: commentId, comment: message, is_fiat: isFiat, is_global_mod: isGlobalMod, is_moderator: isModerator, is_pinned: isPinned, removed, support_amount: supportAmount, timestamp, } = comment; const [hasUserMention, setUserMention] = React.useState(false); const isStreamer = claim && claim.signing_channel && claim.signing_channel.permanent_url === authorUri; const { claimName } = parseURI(authorUri || ''); const stickerUrlFromMessage = getStickerUrl(message); const isSticker = Boolean(stickerUrlFromMessage); const timePosted = timestamp * 1000; const commentIsMine = comment.channel_id && isMyComment(comment.channel_id); // todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine function isMyComment(channelId: string) { return myChannelIds ? myChannelIds.includes(channelId) : false; } // For every new component that is rendered on mobile view, // keep the scroll at the bottom (newest) React.useEffect(() => { if (isMobile && restoreScrollPos) { restoreScrollPos(); } }, [isMobile, restoreScrollPos]); return (
  • 0, 'livestream__comment--sticker': isSticker, 'livestream__comment--mentioned': hasUserMention, 'livestream__comment--mobile': isMobile, })} > {supportAmount > 0 && (
    )}
    {supportAmount > 0 && }
    {isGlobalMod && } {isModerator && } {isStreamer && } {isPinned && ( {__('Pinned')} )} {/* Use key to force timestamp update */} {isSticker ? (
    ) : (
    {removed ? ( ) : ( )}
    )}
  • ); }