guard the unauthed chat status queries
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import {type DidString} from '@atproto/syntax'
|
import {type DidString} from '@atproto/syntax'
|
||||||
import {useQuery} from '@tanstack/react-query'
|
import {useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {useChatClient} from '#/state/session'
|
import {useChatClient, useSession} from '#/state/session'
|
||||||
import {chat} from '#/lexicons'
|
import {chat} from '#/lexicons'
|
||||||
import {STALE} from '..'
|
import {STALE} from '..'
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@ export function useGetConvoAvailabilityQuery(
|
|||||||
{enabled = true}: {enabled?: boolean} = {},
|
{enabled = true}: {enabled?: boolean} = {},
|
||||||
) {
|
) {
|
||||||
const client = useChatClient()
|
const client = useChatClient()
|
||||||
|
const {hasSession} = useSession()
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: RQKEY(did),
|
queryKey: RQKEY(did),
|
||||||
@@ -23,6 +24,6 @@ export function useGetConvoAvailabilityQuery(
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
staleTime: STALE.INFINITY,
|
staleTime: STALE.INFINITY,
|
||||||
enabled,
|
enabled: enabled && hasSession,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {useQuery} from '@tanstack/react-query'
|
import {useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {useChatClient} from '#/state/session'
|
import {useChatClient, useSession} from '#/state/session'
|
||||||
import {chat} from '#/lexicons'
|
import {chat} from '#/lexicons'
|
||||||
import {STALE} from '..'
|
import {STALE} from '..'
|
||||||
import {createQueryKey} from '../util'
|
import {createQueryKey} from '../util'
|
||||||
@@ -10,6 +10,7 @@ const chatActorStatusQueryKey = () =>
|
|||||||
|
|
||||||
export function useChatActorStatusQuery() {
|
export function useChatActorStatusQuery() {
|
||||||
const client = useChatClient()
|
const client = useChatClient()
|
||||||
|
const {hasSession} = useSession()
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
gcTime: STALE.INFINITY,
|
gcTime: STALE.INFINITY,
|
||||||
@@ -18,5 +19,6 @@ export function useChatActorStatusQuery() {
|
|||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
return await client.call(chat.bsky.actor.getStatus)
|
return await client.call(chat.bsky.actor.getStatus)
|
||||||
},
|
},
|
||||||
|
enabled: hasSession,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user