···44import { validate as isValid } from 'uuid';
55import { ContextVariables } from "../auth";
66import { PostEdit } from "../layout/editPost";
77-import { ScheduledPost, ScheduledPostList } from "../layout/postList";
77+import { PostHTML } from "../layout/post";
88+import { ScheduledPostList } from "../layout/postList";
89import { authMiddleware } from "../middleware/auth";
910import { corsHelperMiddleware } from "../middleware/corsHelper";
1011import {
···174175 originalPost.text = content;
175176 c.header("HX-Trigger-After-Settle", `{"scrollListToPost": "${id}"}`);
176177 c.header("HX-Trigger-After-Swap", "postUpdatedNotice, timeSidebar, scrollTop");
177177- return c.html(<ScheduledPost post={originalPost} dynamic={true} />);
178178+ return c.html(<PostHTML post={originalPost} dynamic={true} />);
178179 }
179180180181 c.header("HX-Trigger-After-Settle", swapErrEvents);
···190191 // Get the original post to replace with
191192 if (postInfo !== null) {
192193 c.header("HX-Trigger-After-Swap", "timeSidebar, scrollListTop, scrollTop");
193193- return c.html(<ScheduledPost post={postInfo} dynamic={true} />);
194194+ return c.html(<PostHTML post={postInfo} dynamic={true} />);
194195 }
195196196197 // Refresh sidebar otherwise
+2-2
src/layout/editPost.tsx
···11import { MAX_LENGTH } from "../limits";
22import { EmbedDataType, Post } from "../types.d";
33-import { PostContentObject } from "./postList";
33+import { PostContent } from "./post";
4455type EditedPostProps = {
66 post: Post;
···4545export function PostEdit({post}:EditedPostProps) {
4646 // If this post is posted, just show the same object again.
4747 if (post.posted) {
4848- return (<PostContentObject text={post.text} posted={true} repost={false} />);
4848+ return (<PostContent text={post.text} posted={true} repost={false} />);
4949 }
50505151 const editSpinner: string = `editSpinner${post.postid}`;
+1-1
src/layout/makePost.tsx
···1212} from "../limits";
1313import { PreloadRules } from "../types.d";
1414import { ConstScriptPreload } from "../utils/constScriptGen";
1515-import { ContentLabelOptions } from "./options/contentLabelOptions";
1615import { IncludeDependencyTags } from "./helpers/includesTags";
1616+import { ContentLabelOptions } from "./options/contentLabelOptions";
1717import { RetweetOptions } from "./options/retweetOptions";
1818import { ScheduleOptions } from "./options/scheduleOptions";
1919
+43
src/layout/post.tsx
···11+import { html } from "hono/html";
22+import { MAX_POSTED_LENGTH } from "../limits";
33+import { Post } from "../types.d";
44+import { PostDataFooter, PostDataHeader } from "./posts/wrappers";
55+66+type PostContentProps = {
77+ text: string;
88+ posted: boolean;
99+ repost: boolean;
1010+};
1111+1212+export function PostContent(props: PostContentProps) {
1313+ const ellipses = props.posted && !props.repost && props.text.length >= (MAX_POSTED_LENGTH-1) ? "..." : "";
1414+ return (<p class="postText">{props.text}{ellipses}</p>);
1515+};
1616+1717+type ScheduledPostOptions = {
1818+ post: Post;
1919+ // if the object should be dynamically replaced.
2020+ // usually in edit/cancel edit settings.
2121+ dynamic?: boolean;
2222+};
2323+2424+export function PostHTML(props: ScheduledPostOptions) {
2525+ const content: Post = props.post;
2626+ const oobSwapStr = (props.dynamic) ? `hx-swap-oob="#postBase${content.postid}"` : "";
2727+ const hasBeenPosted: boolean = (content.posted === true && content.uri !== undefined);
2828+2929+ const postHTML = html`
3030+ <article
3131+ id="postBase${content.postid}" ${oobSwapStr}>
3232+ ${<PostDataHeader content={content} posted={hasBeenPosted} />}
3333+ <div id="post${content.postid}">
3434+ ${<PostContent text={content.text} posted={content.posted || false} repost={content.isRepost || false} />}
3535+ </div>
3636+ ${<PostDataFooter content={content} posted={hasBeenPosted} />}
3737+ </article>`;
3838+ // if this is a thread, chain it nicely
3939+ if (content.isChildPost)
4040+ return html`<blockquote>${postHTML}</blockquote>`;
4141+4242+ return postHTML;
4343+};