import { cn } from "@/lib/utils/cn" import { CommentInfo } from "@/types/general" import { useEffect, useState } from "react" import { DefaultAvatar } from "../default-avatar" import { formatTimeAgo } from "@/lib/formatters/formatTimeAgo" import { CommentWithTimeSeeks } from "./time-seeker" export function CommentCard({ comment, replies = [] }: { comment?: CommentInfo, replies: CommentInfo[] }) { const isLongContent = (comment?.message.length || 0) > 370 const [userThumbnail, setUserThumbnail] = useState(comment?.userInfo?.thumbnail || "") const [isExpanded, setExpanded] = useState(false) useEffect(() => { setUserThumbnail(comment?.userInfo?.thumbnail || "") }, [comment?.userInfo?.thumbnail]) if (!comment) { return null } const handleBadUserThumbnail = () => { try { if (userThumbnail) { setUserThumbnail("") } } catch (err) { } } return (
{/* THE COMMENT INFO - HORIZONTAL */}
{ userThumbnail ?
: }
{/* USER INFO AND ACTUAL MESSAGE */}
@{comment?.userInfo?.userName}
{formatTimeAgo(comment.updatedAt)}
{ try { const videoElement: HTMLVideoElement | undefined = (document.getElementsByClassName("tuby-container")?.[0]?.children?.[0] as any) if (videoElement) { videoElement.currentTime = timeInSec } } catch (err) { // } }}>{ comment.message } {isLongContent &&
{ setExpanded(!isExpanded) }} > {isExpanded ? 'Read less' : 'Read more'}
}
{/* THE REPLIES */} {/* TODO */}
) }