about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/data')
-rw-r--r--src/data/index.ts5
-rw-r--r--src/data/useGetProfile.ts26
2 files changed, 8 insertions, 23 deletions
diff --git a/src/data/index.ts b/src/data/index.ts
new file mode 100644
index 000000000..ae3d1595c
--- /dev/null
+++ b/src/data/index.ts
@@ -0,0 +1,5 @@
+import {BskyAgent} from '@atproto/api'
+
+export const PUBLIC_BSKY_AGENT = new BskyAgent({
+  service: 'https://api.bsky.app',
+})
diff --git a/src/data/useGetProfile.ts b/src/data/useGetProfile.ts
index 58f24a4e8..5e0ab907d 100644
--- a/src/data/useGetProfile.ts
+++ b/src/data/useGetProfile.ts
@@ -1,32 +1,12 @@
-import React from 'react'
 import {useQuery} from '@tanstack/react-query'
-import {BskyAgent} from '@atproto/api'
 
-import {useSession} from '#/state/session'
+import {PUBLIC_BSKY_AGENT} from '#/data'
 
 export function useGetProfile({did}: {did: string}) {
-  const {accounts} = useSession()
-  const account = React.useMemo(
-    () => accounts.find(a => a.did === did),
-    [did, accounts],
-  )
-
   return useQuery({
-    enabled: !!account,
-    queryKey: ['getProfile', account],
+    queryKey: ['getProfile', did],
     queryFn: async () => {
-      if (!account) {
-        throw new Error(`useGetProfile: local account not found for ${did}`)
-      }
-
-      const agent = new BskyAgent({
-        // needs to be public data, so remap PDS URLs to App View for now
-        service: account.service.includes('bsky.social')
-          ? 'https://api.bsky.app'
-          : account.service,
-      })
-
-      const res = await agent.getProfile({actor: did})
+      const res = await PUBLIC_BSKY_AGENT.getProfile({actor: did})
       return res.data
     },
   })