11import React from 'react'
2- import { useMutation , useQueryClient } from '@tanstack/react-query '
2+ import { fetchQueryWithFallback , useMutation , useQueryClient } from './useQueryWithFallback '
33
44import { STALE } from '#/state/queries'
55import { useAgent } from '#/state/session'
@@ -19,10 +19,12 @@ export function useFetchHandle() {
1919 return React . useCallback (
2020 async ( handleOrDid : string ) => {
2121 if ( handleOrDid . startsWith ( 'did:' ) ) {
22- const res = await queryClient . fetchQuery ( {
23- staleTime : STALE . MINUTES . FIVE ,
22+ const res = await fetchQueryWithFallback ( queryClient , {
2423 queryKey : fetchHandleQueryKey ( handleOrDid ) ,
2524 queryFn : ( ) => agent . getProfile ( { actor : handleOrDid } ) ,
25+ enableFallback : true ,
26+ fallbackType : 'profile' ,
27+ fallbackIdentifier : handleOrDid ,
2628 } )
2729 return res . data . handle
2830 }
@@ -57,8 +59,7 @@ export function useFetchDid() {
5759
5860 return React . useCallback (
5961 async ( handleOrDid : string ) => {
60- return queryClient . fetchQuery ( {
61- staleTime : STALE . INFINITY ,
62+ return fetchQueryWithFallback ( queryClient , {
6263 queryKey : fetchDidQueryKey ( handleOrDid ) ,
6364 queryFn : async ( ) => {
6465 let identifier = handleOrDid
@@ -68,6 +69,9 @@ export function useFetchDid() {
6869 }
6970 return identifier
7071 } ,
72+ enableFallback : true ,
73+ fallbackType : 'profile' ,
74+ fallbackIdentifier : handleOrDid ,
7175 } )
7276 } ,
7377 [ queryClient , agent ] ,
0 commit comments