From c1b444fbeb84b3e8d532d9a5f47e3ed9c4df0e28 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 14 Feb 2024 19:01:54 +0800 Subject: [PATCH] :lipstick: Optimized post controls --- pkg/view/src/components/posts/PostItem.tsx | 139 ++++++++++++--------- 1 file changed, 77 insertions(+), 62 deletions(-) diff --git a/pkg/view/src/components/posts/PostItem.tsx b/pkg/view/src/components/posts/PostItem.tsx index b04e7a2..aba4784 100644 --- a/pkg/view/src/components/posts/PostItem.tsx +++ b/pkg/view/src/components/posts/PostItem.tsx @@ -5,19 +5,19 @@ import * as marked from "marked"; import DOMPurify from "dompurify"; export default function PostItem(props: { - post: any, - noClick?: boolean, - noAuthor?: boolean, - noControl?: boolean, - noRelated?: boolean, - noContent?: boolean, - onRepost?: (post: any) => void, - onReply?: (post: any) => void, - onEdit?: (post: any) => void, - onDelete?: (post: any) => void, - onSearch?: (filter: any) => void, - onError: (message: string | null) => void, - onReact: () => void + post: any; + noClick?: boolean; + noAuthor?: boolean; + noControl?: boolean; + noRelated?: boolean; + noContent?: boolean; + onRepost?: (post: any) => void; + onReply?: (post: any) => void; + onEdit?: (post: any) => void; + onDelete?: (post: any) => void; + onSearch?: (filter: any) => void; + onError: (message: string | null) => void; + onReact: () => void; }) { const [reacting, setReacting] = createSignal(false); @@ -27,7 +27,7 @@ export default function PostItem(props: { setReacting(true); const res = await fetch(`/api/posts/${item.id}/react/${type}`, { method: "POST", - headers: { "Authorization": `Bearer ${getAtk()}` } + headers: { Authorization: `Bearer ${getAtk()}` }, }); if (res.status !== 201 && res.status !== 204) { props.onError(await res.text()); @@ -38,9 +38,7 @@ export default function PostItem(props: { setReacting(false); } - const content = ( -
- ); + const content =
; return (
@@ -49,8 +47,10 @@ export default function PostItem(props: {
- {props.post.author.name.substring(0, 1)}}> + {props.post.author.name.substring(0, 1)}} + > avatar
@@ -69,27 +69,25 @@ export default function PostItem(props: {

{props.post.title}

- - {content} - + {content}
- {item => + {(item) => ( {item.name} - } + )} - {item => + {(item) => ( {item.name} - } + )}
@@ -105,12 +103,7 @@ export default function PostItem(props: { Reposted a post

- +
@@ -119,12 +112,7 @@ export default function PostItem(props: { Replied a post

- +
@@ -133,58 +121,85 @@ export default function PostItem(props: {
-
+
Login! To access entire platform.
-
+
-
-
-
-
- -
+
+
+
+ +
-
- -
+
+ +
+
@@ -193,4 +208,4 @@ export default function PostItem(props: {
); -} \ No newline at end of file +}