2023-11-15 16:15:44 +01:00
|
|
|
import { Entity, MegalodonInterface } from 'megalodon'
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
import { Virtuoso } from 'react-virtuoso'
|
|
|
|
import Status from '../timelines/status/Status'
|
2023-12-11 16:00:44 +01:00
|
|
|
import { Account } from '@/db'
|
2023-11-15 16:15:44 +01:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
client: MegalodonInterface
|
2023-12-11 16:00:44 +01:00
|
|
|
account: Account
|
2023-11-15 16:15:44 +01:00
|
|
|
status_id: string
|
2023-12-02 11:26:45 +01:00
|
|
|
openMedia: (media: Entity.Attachment) => void
|
2023-11-15 16:15:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default function Thread(props: Props) {
|
|
|
|
const [ancestors, setAncestors] = useState<Array<Entity.Status>>([])
|
|
|
|
const [descendants, setDescendants] = useState<Array<Entity.Status>>([])
|
|
|
|
const [status, setStatus] = useState<Entity.Status | null>(null)
|
|
|
|
|
|
|
|
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)
|
|
|
|
setDescendants(res.data.descendants)
|
|
|
|
}
|
|
|
|
f()
|
|
|
|
}
|
|
|
|
}, [props.status_id])
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Virtuoso
|
2023-11-17 15:01:54 +01:00
|
|
|
style={{ height: 'calc(100% - 50px)' }}
|
2024-01-02 05:24:18 +01:00
|
|
|
className="timeline-scrollable"
|
2023-11-15 16:15:44 +01:00
|
|
|
data={[...ancestors, status, ...descendants].filter(s => s !== null)}
|
2023-12-02 11:26:45 +01:00
|
|
|
itemContent={(_, status) => (
|
2023-12-11 16:00:44 +01:00
|
|
|
<Status
|
|
|
|
client={props.client}
|
|
|
|
account={props.account}
|
|
|
|
status={status}
|
|
|
|
key={status.id}
|
|
|
|
onRefresh={() => {}}
|
|
|
|
openMedia={props.openMedia}
|
2024-02-27 12:49:27 +01:00
|
|
|
filters={[]}
|
2023-12-11 16:00:44 +01:00
|
|
|
/>
|
2023-12-02 11:26:45 +01:00
|
|
|
)}
|
2023-11-15 16:15:44 +01:00
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|