diff options
author | crupest <crupest@outlook.com> | 2023-09-14 18:58:44 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-09-20 18:50:08 +0800 |
commit | bdc69c18c1986544497b6974ffe5d8e073e4be6d (patch) | |
tree | 4283f2fcc4af9b8849588e8db21e4f52d136a1e7 /FrontEnd/src/pages/timeline/view/PlainTextPostView.tsx | |
parent | aef14be13c3bd9e93eeea598dbfbf707ba98d448 (diff) | |
download | timeline-bdc69c18c1986544497b6974ffe5d8e073e4be6d.tar.gz timeline-bdc69c18c1986544497b6974ffe5d8e073e4be6d.tar.bz2 timeline-bdc69c18c1986544497b6974ffe5d8e073e4be6d.zip |
...
Diffstat (limited to 'FrontEnd/src/pages/timeline/view/PlainTextPostView.tsx')
-rw-r--r-- | FrontEnd/src/pages/timeline/view/PlainTextPostView.tsx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/FrontEnd/src/pages/timeline/view/PlainTextPostView.tsx b/FrontEnd/src/pages/timeline/view/PlainTextPostView.tsx new file mode 100644 index 00000000..b964187d --- /dev/null +++ b/FrontEnd/src/pages/timeline/view/PlainTextPostView.tsx @@ -0,0 +1,50 @@ +import { useState } from "react"; +import classNames from "classnames"; + +import { + HttpTimelinePostInfo, + getHttpTimelineClient, +} from "~src/http/timeline"; + +import Skeleton from "~src/components/Skeleton"; +import { useAutoUnsubscribePromise } from "~src/components/hooks"; + +import "./PlainTextPostView.css"; + +interface PlainTextPostViewProps { + post?: HttpTimelinePostInfo; + className?: string; +} + +export default function PlainTextPostView({ + post, + className, +}: PlainTextPostViewProps) { + const [text, setText] = useState<string | null>(null); + + useAutoUnsubscribePromise( + () => { + if (post) { + return getHttpTimelineClient().getPostDataAsString( + post.timelineOwnerV2, + post.timelineNameV2, + post.id, + ); + } + }, + setText, + [post], + ); + + return ( + <div + className={classNames("timeline-view-plain-text-container", className)} + > + {text == null ? ( + <Skeleton /> + ) : ( + <div className="timeline-view-plain-text">{text}</div> + )} + </div> + ); +} |