about summary refs log tree commit diff
path: root/src/state/queries
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-01-26 05:23:56 +0000
committerGitHub <noreply@github.com>2024-01-25 21:23:56 -0800
commit23a4bbf6082a7d02c7dbf0af74f81e2200327eb0 (patch)
treebf3d5151cf84b22a38cd014be4109a5a946242b2 /src/state/queries
parent157404132f43dc4fc42437fe27348a491161f241 (diff)
downloadvoidsky-23a4bbf6082a7d02c7dbf0af74f81e2200327eb0.tar.zst
Prefetch profile links on web (#2634)
Diffstat (limited to 'src/state/queries')
-rw-r--r--src/state/queries/profile.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts
index e6203550f..74be99330 100644
--- a/src/state/queries/profile.ts
+++ b/src/state/queries/profile.ts
@@ -57,6 +57,23 @@ export function useProfilesQuery({handles}: {handles: string[]}) {
   })
 }
 
+export function usePrefetchProfileQuery() {
+  const queryClient = useQueryClient()
+  const prefetchProfileQuery = useCallback(
+    (did: string) => {
+      queryClient.prefetchQuery({
+        queryKey: RQKEY(did),
+        queryFn: async () => {
+          const res = await getAgent().getProfile({actor: did || ''})
+          return res.data
+        },
+      })
+    },
+    [queryClient],
+  )
+  return prefetchProfileQuery
+}
+
 interface ProfileUpdateParams {
   profile: AppBskyActorDefs.ProfileView
   updates: