blob: 851a9a33d99e7aa0bce7ce9a325eca477ce417bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import ImagePostView from "./ImagePostView";
import MarkdownPostView from "./MarkdownPostView";
import PlainTextPostView from "./PlainTextPostView";
import type { HttpTimelinePostInfo } from "~src/http/timeline";
interface TimelinePostContentViewProps {
post?: HttpTimelinePostInfo;
className?: string;
}
const viewMap: Record<string, React.FC<TimelinePostContentViewProps>> = {
"text/plain": PlainTextPostView,
"text/markdown": MarkdownPostView,
"image/png": ImagePostView,
"image/jpeg": ImagePostView,
"image/gif": ImagePostView,
"image/webp": ImagePostView,
};
export default function TimelinePostContentView({
post,
className,
}: TimelinePostContentViewProps) {
if (post == null) {
return <div />;
}
const type = post.dataList[0].kind;
if (type in viewMap) {
const View = viewMap[type];
return <View post={post} className={className} />;
}
return <div>Unknown post type.</div>;
}
|