Block posting of invalid chat invites (#10757)
Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {type BskyAgent} from '@atproto/api'
|
||||
import {type QueryClient, useQuery} from '@tanstack/react-query'
|
||||
import {type AtpAgent} from '@atproto/api'
|
||||
import {type QueryClient, queryOptions, useQuery} from '@tanstack/react-query'
|
||||
|
||||
import {type ResolvedLink, resolveGif, resolveLink} from '#/lib/api/resolve'
|
||||
import {STALE} from '#/state/queries/index'
|
||||
@@ -12,29 +12,24 @@ export const RQKEY_LINK = (url: string) => [RQKEY_LINK_ROOT, url]
|
||||
export const RQKEY_GIF_ROOT = 'resolve-gif'
|
||||
export const RQKEY_GIF = (url: string) => [RQKEY_GIF_ROOT, url]
|
||||
|
||||
export function useResolveLinkQuery(url: string) {
|
||||
const agent = useAgent()
|
||||
|
||||
return useQuery({
|
||||
export function resolveLinkQueryOptions(agent: AtpAgent, url: string) {
|
||||
return queryOptions({
|
||||
staleTime: STALE.HOURS.ONE,
|
||||
queryKey: RQKEY_LINK(url),
|
||||
queryFn: async () => {
|
||||
return await resolveLink(agent, url)
|
||||
},
|
||||
queryFn: () => resolveLink(agent, url),
|
||||
})
|
||||
}
|
||||
|
||||
export function useResolveLinkQuery(url: string) {
|
||||
const agent = useAgent()
|
||||
return useQuery(resolveLinkQueryOptions(agent, url))
|
||||
}
|
||||
export function fetchResolveLinkQuery(
|
||||
queryClient: QueryClient,
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
url: string,
|
||||
) {
|
||||
return queryClient.fetchQuery({
|
||||
staleTime: STALE.HOURS.ONE,
|
||||
queryKey: RQKEY_LINK(url),
|
||||
queryFn: async () => {
|
||||
return await resolveLink(agent, url)
|
||||
},
|
||||
})
|
||||
return queryClient.fetchQuery(resolveLinkQueryOptions(agent, url))
|
||||
}
|
||||
export function precacheResolveLinkQuery(
|
||||
queryClient: QueryClient,
|
||||
@@ -56,7 +51,7 @@ export function useResolveGifQuery(gif: Gif) {
|
||||
}
|
||||
export function fetchResolveGifQuery(
|
||||
queryClient: QueryClient,
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
gif: Gif,
|
||||
) {
|
||||
return queryClient.fetchQuery({
|
||||
|
||||
Reference in New Issue
Block a user