From b279cb9c8ba2484cd16ee160d3e74c6bcc614f9b Mon Sep 17 00:00:00 2001 From: rimar1337 <132627503+rimar1337@users.noreply.github.com> Date: Tue, 21 Oct 2025 08:45:24 +0700 Subject: [PATCH] constellation profilething --- src/components/Login.tsx | 45 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/components/Login.tsx b/src/components/Login.tsx index 476d51c..2e340f9 100644 --- a/src/components/Login.tsx +++ b/src/components/Login.tsx @@ -1,8 +1,9 @@ // src/components/Login.tsx -import { Agent } from "@atproto/api"; +import AtpAgent, { Agent } from "@atproto/api"; import React, { useEffect, useRef, useState } from "react"; import { useAuth } from "~/providers/UnifiedAuthProvider"; +import { useQueryIdentity, useQueryProfile } from "~/utils/useQuery"; // --- 1. The Main Component (Orchestrator with `compact` prop) --- export default function Login({ @@ -110,7 +111,7 @@ export function UnifiedLoginForm() { // --- 3. Helper components for layouts, forms, and UI --- // A new component to contain the logic for the compact dropdown -const CompactLoginButton = ({popup}:{popup?: boolean}) => { +const CompactLoginButton = ({ popup }: { popup?: boolean }) => { const [showForm, setShowForm] = useState(false); const formRef = useRef(null); @@ -137,7 +138,9 @@ const CompactLoginButton = ({popup}:{popup?: boolean}) => { Log in {showForm && ( -
+
)} @@ -268,29 +271,27 @@ const PasswordForm = () => { // --- Profile Component (now supports a `large` prop for styling) --- export const ProfileThing = ({ - agent, + agent: _unused, large = false, }: { - agent: Agent | null; + agent?: Agent | null; large?: boolean; }) => { - const [profile, setProfile] = useState(null); + const { agent } = useAuth(); + const did = ((agent as AtpAgent).session?.did ?? (agent as AtpAgent)?.assertDid ?? agent?.did) as + | string + | undefined; + const { data: identity } = useQueryIdentity(did); + const { data: profiledata } = useQueryProfile(`at://${did}/app.bsky.actor.profile/self`); + const profile = profiledata?.value; - useEffect(() => { - const fetchUser = async () => { - const did = (agent as any)?.session?.did ?? (agent as any)?.assertDid; - if (!did) return; - try { - const res = await agent!.getProfile({ actor: did }); - setProfile(res.data); - } catch (e) { - console.error("Failed to fetch profile", e); - } - }; - if (agent) fetchUser(); - }, [agent]); + function getAvatarUrl(p: typeof profile) { + const link = p?.avatar?.ref?.["$link"]; + if (!link || !did) return null; + return `https://cdn.bsky.app/img/avatar/plain/${did}/${link}@jpeg`; + } - if (!profile) { + if (!profiledata) { return ( // Skeleton loader
avatar @@ -329,7 +330,7 @@ export const ProfileThing = ({
- @{profile?.handle} + @{identity?.handle}
-- 2.51.2