blob: 649d2db74963892a4d46b3696e24702b29a98313 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import {useQuery} from '@tanstack/react-query'
import {resolveShortLink} from '#/lib/link-meta/resolve-short-link'
import {parseStarterPackUri} from '#/lib/strings/starter-pack'
import {STALE} from '#/state/queries/index'
const ROOT_URI = 'https://go.bsky.app/'
const RQKEY_ROOT = 'resolved-short-link'
export const RQKEY = (code: string) => [RQKEY_ROOT, code]
export function useResolvedStarterPackShortLink({code}: {code: string}) {
return useQuery({
queryKey: RQKEY(code),
queryFn: async () => {
const uri = `${ROOT_URI}${code}`
const res = await resolveShortLink(uri)
return parseStarterPackUri(res)
},
retry: 1,
enabled: Boolean(code),
staleTime: STALE.HOURS.ONE,
})
}
|