From 84cb2739411fad84afeeceb5dcff998b1b7d27a9 Mon Sep 17 00:00:00 2001 From: gosangam Date: Thu, 18 Jun 2026 00:21:06 +0530 Subject: [PATCH] fix: feed card follow ui --- components/social/post/feed-follow-button.tsx | 16 ++++++--- components/social/post/post-card.tsx | 24 ++++++++++--- components/social/post/post-scroll-card.tsx | 35 +++++++++++++------ lib/social.ts | 3 ++ 4 files changed, 59 insertions(+), 19 deletions(-) diff --git a/components/social/post/feed-follow-button.tsx b/components/social/post/feed-follow-button.tsx index 5468ceed..2d5ecbd0 100644 --- a/components/social/post/feed-follow-button.tsx +++ b/components/social/post/feed-follow-button.tsx @@ -18,22 +18,30 @@ import { useAuthGate } from "@/components/auth/auth-gate"; export function FeedFollowButton({ handle, followsYou, + requested = false, }: { handle: string; /** The author already follows the viewer → label becomes "Follow back". */ followsYou: boolean; + /** Server-truth: the viewer already has a pending follow request to this + * author (e.g. sent in a prior session or on the profile page). */ + requested?: boolean; }) { const { requireAuth } = useAuthGate(); - const [requested, setRequested] = useState(false); + const [justRequested, setJustRequested] = useState(false); const [busy, setBusy] = useState(false); + // Show "Requested" when the server already knows about a pending request or + // the viewer just sent one in this session. + const showRequested = requested || justRequested; + async function follow() { - if (busy || requested) return; + if (busy || showRequested) return; if (!(await requireAuth())) return; setBusy(true); try { await relationships.follow(handle); - setRequested(true); + setJustRequested(true); } catch (err) { toast.error( err instanceof SocialError ? err.message : "Could not follow", @@ -44,7 +52,7 @@ export function FeedFollowButton({ } } - if (requested) { + if (showRequested) { return ( diff --git a/components/social/post/post-card.tsx b/components/social/post/post-card.tsx index 690512c8..a150e7d1 100644 --- a/components/social/post/post-card.tsx +++ b/components/social/post/post-card.tsx @@ -71,11 +71,25 @@ export function PostCard({ show (delete for owners, block/report for everyone else), so a view with nothing to expose simply hides the dot. */}
- + {authorHandle ? ( + + + + ) : ( + + )}
{authorHandle ? ( - + {post.author_handle ? ( + + + + ) : ( + + )}
{post.author_name || "Unknown"} - {post.author_handle ? ( - - @{post.author_handle} - - ) : null} + + {post.author_handle ? <>@{post.author_handle} · : null} + {timeAgo(post.created_at)} +
{enableFollow && post.author_handle && !post.viewer_follows_author ? ( ) : null}