From 0119174969eaeb6848fe7463f41a1908d0f99f1e Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 20 Jan 2026 06:45:06 +0000 Subject: [PATCH] Add category icons & author avatars to PostDetailModal (v0.0.88) - Category icon shown when post has no image (with gradient background) - Author avatar fetched from profile API and displayed - Logo position adjusted (6px down, 1px left) - Comments auto-open when existing comments present Co-Authored-By: Claude Opus 4.5 --- package.json | 2 +- src/components/Layout/TopBarNew.jsx | 2 +- src/components/Posts/PostDetailModal.jsx | 47 +++++++++++++++++++++--- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 539da78..e0761f2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sociowire-frontend", "private": true, - "version": "0.0.87", + "version": "0.0.88", "type": "module", "scripts": { "dev": "vite --host 0.0.0.0", diff --git a/src/components/Layout/TopBarNew.jsx b/src/components/Layout/TopBarNew.jsx index 1cec67a..55ecc3b 100644 --- a/src/components/Layout/TopBarNew.jsx +++ b/src/components/Layout/TopBarNew.jsx @@ -512,7 +512,7 @@ export default function TopBarNew({ theme = "dark", onChangeTheme, onIslandsClic transition={{ duration: 2, repeat: Infinity }} />
- SocioWire + SocioWire
diff --git a/src/components/Posts/PostDetailModal.jsx b/src/components/Posts/PostDetailModal.jsx index 1fc8416..3206cfa 100644 --- a/src/components/Posts/PostDetailModal.jsx +++ b/src/components/Posts/PostDetailModal.jsx @@ -16,6 +16,7 @@ import { editPost, deletePost, updatePostVisibility, + fetchProfile, } from "../../api/client"; // ============================================================================ @@ -44,6 +45,25 @@ function formatCount(n) { return num.toString(); } +function categoryIconClass(post) { + const c = (post?.category || "NEWS").toString().toUpperCase(); + switch (c) { + case "EVENT": + case "EVENTS": + return "fa-regular fa-calendar"; + case "FRIENDS": + return "fa-solid fa-user-group"; + case "MARKET": + return "fa-solid fa-store"; + case "CAMERA": + return "fa-solid fa-video"; + case "LIVE": + return "fa-solid fa-tower-broadcast"; + default: + return "fa-regular fa-newspaper"; + } +} + function relativeTime(dateStr, t) { if (!dateStr) return ""; const d = new Date(dateStr); @@ -362,13 +382,14 @@ function HeroStory({ post, gallery, imageIndex, setImageIndex }) { ); } - // No image - show gradient with author + // No image - show gradient with category icon return (
-
-
- {author.charAt(0).toUpperCase()} +
+
+
+ {post?.category || "News"}
); @@ -464,6 +485,7 @@ export default function PostDetailModal({ post, onClose, onPostUpdated, onPostDe }); const [liked, setLiked] = useState(false); const [truth, setTruth] = useState({ score: 50, count: 0 }); + const [authorAvatar, setAuthorAvatar] = useState(""); const [comments, setComments] = useState([]); const [commentInput, setCommentInput] = useState(""); const [commentSending, setCommentSending] = useState(false); @@ -504,6 +526,15 @@ export default function PostDetailModal({ post, onClose, onPostUpdated, onPostDe fetchPostTruth(postId).then(res => { if (res) setTruth({ score: res.truth_score ?? res.user_score ?? 50, count: res.vote_count ?? 0 }); }); }, [postId]); + // Fetch author avatar + useEffect(() => { + const authorName = post?.author || post?.username; + if (!authorName) return; + fetchProfile(authorName).then(res => { + if (res?.avatar_url) setAuthorAvatar(res.avatar_url); + }); + }, [post?.author, post?.username]); + // Fetch comments const refreshComments = useCallback(async (autoOpen = false) => { if (!postId) return; @@ -659,8 +690,12 @@ export default function PostDetailModal({ post, onClose, onPostUpdated, onPostDe {/* Author Row */}
- {author.charAt(0).toUpperCase()} + text-white font-bold text-base sm:text-lg shadow-lg overflow-hidden`}> + {authorAvatar ? ( + {author} + ) : ( + author.charAt(0).toUpperCase() + )}

@{author}