From 86a21a5bb7b5424daf44dc19b6ca7988e19aaa98 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Fri, 15 May 2026 04:13:51 +0200 Subject: [PATCH] feat(frontend): RemoteFollowing component --- .../federation/remote-following.tsx | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 thoughts-frontend/components/federation/remote-following.tsx diff --git a/thoughts-frontend/components/federation/remote-following.tsx b/thoughts-frontend/components/federation/remote-following.tsx new file mode 100644 index 0000000..7f0b260 --- /dev/null +++ b/thoughts-frontend/components/federation/remote-following.tsx @@ -0,0 +1,65 @@ +"use client"; + +import { useEffect, useState } from "react"; +import { getRemoteFollowing, unfollowRemoteActor, type RemoteActor } from "@/lib/api"; +import { useAuth } from "@/hooks/use-auth"; +import { UserAvatar } from "@/components/user-avatar"; +import { Button } from "@/components/ui/button"; +import { toast } from "sonner"; + +export function RemoteFollowing() { + const { token } = useAuth(); + const [following, setFollowing] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + if (!token) return; + getRemoteFollowing(token) + .then(setFollowing) + .catch(() => toast.error("Failed to load following")) + .finally(() => setLoading(false)); + }, [token]); + + const unfollow = async (handle: string) => { + if (!token) return; + setFollowing((prev) => prev.filter((f) => f.handle !== handle)); + await unfollowRemoteActor(handle, token).catch(() => { + toast.error("Failed to unfollow"); + }); + }; + + if (loading) return

Loading…

; + if (following.length === 0) + return

Not following anyone remotely yet.

; + + return ( + + ); +}