fix(frontend): unify local+remote followers/following — profile tab becomes Requests only
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import { getFollowersList } from "@/lib/api";
|
import { getFollowersList, getMe } from "@/lib/api";
|
||||||
import { UserListCard } from "@/components/user-list-card";
|
import { UserListCard } from "@/components/user-list-card";
|
||||||
|
import { RemoteFollowers } from "@/components/federation/remote-followers";
|
||||||
|
|
||||||
interface FollowersPageProps {
|
interface FollowersPageProps {
|
||||||
params: Promise<{ username: string }>;
|
params: Promise<{ username: string }>;
|
||||||
@@ -11,22 +12,33 @@ export default async function FollowersPage({ params }: FollowersPageProps) {
|
|||||||
const { username } = await params;
|
const { username } = await params;
|
||||||
const token = (await cookies()).get("auth_token")?.value ?? null;
|
const token = (await cookies()).get("auth_token")?.value ?? null;
|
||||||
|
|
||||||
const followersData = await getFollowersList(username, token).catch(
|
const [followersData, me] = await Promise.all([
|
||||||
() => null
|
getFollowersList(username, token).catch(() => null),
|
||||||
);
|
token ? getMe(token).catch(() => null) : null,
|
||||||
|
]);
|
||||||
|
|
||||||
if (!followersData) {
|
if (!followersData) {
|
||||||
notFound();
|
notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isOwnProfile = me?.username === username;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto max-w-2xl p-4 sm:p-6">
|
<div className="container mx-auto max-w-2xl p-4 sm:p-6">
|
||||||
<header className="my-6">
|
<header className="my-6">
|
||||||
<h1 className="text-3xl font-bold">Followers</h1>
|
<h1 className="text-3xl font-bold">Followers</h1>
|
||||||
<p className="text-muted-foreground">Users following @{username}.</p>
|
<p className="text-muted-foreground">Users following @{username}.</p>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main className="space-y-8">
|
||||||
<UserListCard users={followersData.items} />
|
<UserListCard users={followersData.items} />
|
||||||
|
{isOwnProfile && (
|
||||||
|
<section>
|
||||||
|
<h2 className="text-sm font-semibold text-muted-foreground uppercase tracking-wide mb-3">
|
||||||
|
Remote followers
|
||||||
|
</h2>
|
||||||
|
<RemoteFollowers />
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import { getFollowingList } from "@/lib/api";
|
import { getFollowingList, getMe } from "@/lib/api";
|
||||||
import { UserListCard } from "@/components/user-list-card";
|
import { UserListCard } from "@/components/user-list-card";
|
||||||
|
import { RemoteFollowing } from "@/components/federation/remote-following";
|
||||||
|
|
||||||
interface FollowingPageProps {
|
interface FollowingPageProps {
|
||||||
params: Promise<{ username: string }>;
|
params: Promise<{ username: string }>;
|
||||||
@@ -11,22 +12,33 @@ export default async function FollowingPage({ params }: FollowingPageProps) {
|
|||||||
const { username } = await params;
|
const { username } = await params;
|
||||||
const token = (await cookies()).get("auth_token")?.value ?? null;
|
const token = (await cookies()).get("auth_token")?.value ?? null;
|
||||||
|
|
||||||
const followingData = await getFollowingList(username, token).catch(
|
const [followingData, me] = await Promise.all([
|
||||||
() => null
|
getFollowingList(username, token).catch(() => null),
|
||||||
);
|
token ? getMe(token).catch(() => null) : null,
|
||||||
|
]);
|
||||||
|
|
||||||
if (!followingData) {
|
if (!followingData) {
|
||||||
notFound();
|
notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isOwnProfile = me?.username === username;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto max-w-2xl p-4 sm:p-6">
|
<div className="container mx-auto max-w-2xl p-4 sm:p-6">
|
||||||
<header className="my-6">
|
<header className="my-6">
|
||||||
<h1 className="text-3xl font-bold">Following</h1>
|
<h1 className="text-3xl font-bold">Following</h1>
|
||||||
<p className="text-muted-foreground">Users that @{username} follows.</p>
|
<p className="text-muted-foreground">Users that @{username} follows.</p>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main className="space-y-8">
|
||||||
<UserListCard users={followingData.items} />
|
<UserListCard users={followingData.items} />
|
||||||
|
{isOwnProfile && (
|
||||||
|
<section>
|
||||||
|
<h2 className="text-sm font-semibold text-muted-foreground uppercase tracking-wide mb-3">
|
||||||
|
Remote following
|
||||||
|
</h2>
|
||||||
|
<RemoteFollowing />
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ import { ThoughtThread } from "@/components/thought-thread";
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { FederationPanel } from "@/components/federation/federation-panel";
|
import { PendingRequests } from "@/components/federation/pending-requests";
|
||||||
|
|
||||||
interface ProfilePageProps {
|
interface ProfilePageProps {
|
||||||
params: Promise<{ username: string }>;
|
params: Promise<{ username: string }>;
|
||||||
@@ -256,7 +256,7 @@ export default async function ProfilePage({ params }: ProfilePageProps) {
|
|||||||
<TabsList className="mb-4">
|
<TabsList className="mb-4">
|
||||||
<TabsTrigger value="thoughts">Thoughts</TabsTrigger>
|
<TabsTrigger value="thoughts">Thoughts</TabsTrigger>
|
||||||
{isOwnProfile && (
|
{isOwnProfile && (
|
||||||
<TabsTrigger value="federation">Federation</TabsTrigger>
|
<TabsTrigger value="federation">Requests</TabsTrigger>
|
||||||
)}
|
)}
|
||||||
</TabsList>
|
</TabsList>
|
||||||
<TabsContent value="thoughts" className="space-y-4">
|
<TabsContent value="thoughts" className="space-y-4">
|
||||||
@@ -281,7 +281,7 @@ export default async function ProfilePage({ params }: ProfilePageProps) {
|
|||||||
</TabsContent>
|
</TabsContent>
|
||||||
{isOwnProfile && (
|
{isOwnProfile && (
|
||||||
<TabsContent value="federation">
|
<TabsContent value="federation">
|
||||||
<FederationPanel />
|
<PendingRequests />
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
)}
|
)}
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|||||||
Reference in New Issue
Block a user