import Item from './item'
import Reply from './reply'
import Comment from './comment'
import Text from './text'
import Comments from './comments'
import styles from '../styles/item.module.css'
import { NOFOLLOW_LIMIT } from '../lib/constants'
import { useMe } from './me'
import { Button } from 'react-bootstrap'
import { TwitterTweetEmbed } from 'react-twitter-embed'
import YouTube from 'react-youtube'
import useDarkMode from 'use-dark-mode'
import { useEffect, useRef, useState } from 'react'
function BioItem ({ item, handleClick }) {
const me = useMe()
if (!item.text) {
return null
}
return (
<>
{me?.name === item.user.name &&
}
>
)
}
function TweetSkeleton () {
return (
)
}
function ItemEmbed ({ item }) {
const darkMode = useDarkMode()
const [overflowing, setOverflowing] = useState(false)
const [show, setShow] = useState(false)
const containerRef = useRef(null)
const checkOverflow = () => {
const cont = containerRef.current
const over = cont && (cont.offsetHeight < cont.scrollHeight || cont.offsetWidth < cont.scrollWidth)
if (over) {
setOverflowing(true)
return
}
setOverflowing(false)
}
useEffect(checkOverflow, [])
const twitter = item.url?.match(/^https?:\/\/twitter\.com\/(?:#!\/)?\w+\/status(?:es)?\/(?\d+)/)
if (twitter?.groups?.id) {
return (
} onLoad={checkOverflow} />
{overflowing && !show &&
}
)
}
const youtube = item.url?.match(/(https?:\/\/)?((www\.)?(youtube(-nocookie)?|youtube.googleapis)\.com.*(v\/|v=|vi=|vi\/|e\/|embed\/|user\/.*\/u\/\d+\/)|youtu\.be\/)(?[_0-9a-z-]+)/i)
if (youtube?.groups?.id) {
return (
)
}
return null
}
function TopLevelItem ({ item, noReply, ...props }) {
return (
-
{item.text && }
{item.url && }
{!noReply && }
)
}
function ItemText ({ item }) {
return {item.searchText || item.text}
}
export default function ItemFull ({ item, bio, ...props }) {
return (
<>
{item.parentId
?
: (
{
bio
?
:
}
)}
{item.comments &&
}
>
)
}