import { useState } from "react"; import { useParams } from "react-router-dom"; import { useQuery, useMutation } from "@tanstack/react-query"; import { MessageSquare } from "lucide-react"; import { useAuth } from "../lib/auth"; import { usePageTitle } from "../hooks/usePageTitle"; import { putProfile } from "../lib/writes"; import { myThreadsQuery, profileQuery } from "../lib/queries"; import { queryClient } from "../lib/queryClient"; import ViewProfile from "../components/profile/ViewProfile"; import EditProfile from "../components/profile/EditProfile"; import MyThreadList from "../components/dashboard/MyThreadList"; import ListSkeleton from "../components/layout/ListSkeleton"; export default function Profile() { const { handle } = useParams(); const { user, agent } = useAuth(); const [editing, setEditing] = useState(false); const { data: profile } = useQuery(profileQuery(handle!)); const { data: threads } = useQuery({ ...myThreadsQuery(profile?.pdsUrl ?? "", profile?.did ?? ""), enabled: !!profile, }); usePageTitle(`${profile?.name ?? handle} — atbbs`); const isOwner = user?.handle === handle; const saveProfileMutation = useMutation({ mutationFn: async (input: { name?: string; pronouns?: string; bio?: string; }) => { if (!agent) throw new Error("Not signed in"); await putProfile(agent, input.name, input.pronouns, input.bio); }, onSuccess: () => { queryClient.invalidateQueries(profileQuery(handle!)); setEditing(false); }, }); if (editing) { return ( saveProfileMutation.mutateAsync({ name, pronouns, bio }) } onCancel={() => setEditing(false)} /> ); } return ( <> setEditing(true)} />

Recent Threads

{threads ? ( ) : ( )}
); }