import { MegalodonInterface, Entity } from 'megalodon' import { useEffect, useRef, useState } from 'react' import { Virtuoso } from 'react-virtuoso' import Status from '../timelines/status/Status' import Compose from '../compose/Compose' type Props = { client: MegalodonInterface status_id: string openMedia: (media: Entity.Attachment) => void } export default function Reply(props: Props) { const [ancestors, setAncestors] = useState>([]) const [status, setStatus] = useState(null) const [composeHeight, setComposeHeight] = useState(120) const composeRef = useRef(null) useEffect(() => { const observer = new ResizeObserver(entries => { entries.forEach(el => { setComposeHeight(el.contentRect.height) }) }) if (composeRef.current) { observer.observe(composeRef.current) } return () => { observer.disconnect() } }, []) useEffect(() => { if (props.status_id) { const f = async () => { const s = await props.client.getStatus(props.status_id) setStatus(s.data) const res = await props.client.getStatusContext(props.status_id) setAncestors(res.data.ancestors) } f() } }, [props.status_id]) return (
s !== null)} itemContent={(_, status) => ( {}} openMedia={props.openMedia} /> )} />
) }