fix: enhance top friends display logic in FeedPage
All checks were successful
Build and Deploy Thoughts / build-and-deploy-local (push) Successful in 1m37s

This commit is contained in:
2025-09-14 21:40:48 +02:00
parent e2494135d6
commit dffec9b189

View File

@@ -72,7 +72,10 @@ async function FeedPage({
); );
const friends = (await getFriends(token)).users.map((user) => user.username); const friends = (await getFriends(token)).users.map((user) => user.username);
const shouldDisplayTopFriends = me?.topFriends && me.topFriends.length > 8; const shouldDisplayTopFriends =
token && me?.topFriends && me.topFriends.length > 8;
console.log("Should display top friends:", shouldDisplayTopFriends);
return ( return (
<div className="container mx-auto max-w-6xl p-4 sm:p-6"> <div className="container mx-auto max-w-6xl p-4 sm:p-6">
@@ -92,6 +95,13 @@ async function FeedPage({
<div className="block lg:hidden space-y-6"> <div className="block lg:hidden space-y-6">
<PopularTags /> <PopularTags />
{shouldDisplayTopFriends && (
<TopFriends mode="top-friends" usernames={me.topFriends} />
)}
{!shouldDisplayTopFriends && token && friends.length > 0 && (
<TopFriends mode="friends" usernames={friends || []} />
)}
<UsersCount />
</div> </div>
<div className="space-y-6"> <div className="space-y-6">
@@ -129,11 +139,13 @@ async function FeedPage({
<aside className="hidden lg:block lg:col-span-1"> <aside className="hidden lg:block lg:col-span-1">
<div className="sticky top-20 space-y-6"> <div className="sticky top-20 space-y-6">
<PopularTags />
{shouldDisplayTopFriends && ( {shouldDisplayTopFriends && (
<TopFriends mode="top-friends" usernames={me.topFriends} /> <TopFriends mode="top-friends" usernames={me.topFriends} />
)} )}
<PopularTags /> {!shouldDisplayTopFriends && token && friends.length > 0 && (
{token && <TopFriends mode="friends" usernames={friends || []} />} <TopFriends mode="friends" usernames={friends || []} />
)}
<UsersCount /> <UsersCount />
</div> </div>
</aside> </aside>