[Session] Add useAgent hook and replace (#3706)
* Hook it up * Memoize getAgent method * Use one shared reference --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
This commit is contained in:
parent
d8c8e1e854
commit
45d354cd0c
53 changed files with 231 additions and 114 deletions
|
|
@ -1,24 +1,25 @@
|
|||
import {useState, useEffect} from 'react'
|
||||
import {ImageModel} from 'state/models/media/image'
|
||||
import {useEffect, useState} from 'react'
|
||||
|
||||
import {logger} from '#/logger'
|
||||
import {useFetchDid} from '#/state/queries/handle'
|
||||
import {useGetPost} from '#/state/queries/post'
|
||||
import {useAgent} from '#/state/session'
|
||||
import * as apilib from 'lib/api/index'
|
||||
import {getLinkMeta} from 'lib/link-meta/link-meta'
|
||||
import {POST_IMG_MAX} from 'lib/constants'
|
||||
import {
|
||||
getPostAsQuote,
|
||||
getFeedAsEmbed,
|
||||
getListAsEmbed,
|
||||
getPostAsQuote,
|
||||
} from 'lib/link-meta/bsky'
|
||||
import {getLinkMeta} from 'lib/link-meta/link-meta'
|
||||
import {downloadAndResize} from 'lib/media/manip'
|
||||
import {
|
||||
isBskyPostUrl,
|
||||
isBskyCustomFeedUrl,
|
||||
isBskyListUrl,
|
||||
isBskyPostUrl,
|
||||
} from 'lib/strings/url-helpers'
|
||||
import {ImageModel} from 'state/models/media/image'
|
||||
import {ComposerOpts} from 'state/shell/composer'
|
||||
import {POST_IMG_MAX} from 'lib/constants'
|
||||
import {logger} from '#/logger'
|
||||
import {getAgent} from '#/state/session'
|
||||
import {useGetPost} from '#/state/queries/post'
|
||||
import {useFetchDid} from '#/state/queries/handle'
|
||||
|
||||
export function useExternalLinkFetch({
|
||||
setQuote,
|
||||
|
|
@ -30,6 +31,7 @@ export function useExternalLinkFetch({
|
|||
)
|
||||
const getPost = useGetPost()
|
||||
const fetchDid = useFetchDid()
|
||||
const {getAgent} = useAgent()
|
||||
|
||||
useEffect(() => {
|
||||
let aborted = false
|
||||
|
|
@ -135,7 +137,7 @@ export function useExternalLinkFetch({
|
|||
})
|
||||
}
|
||||
return cleanup
|
||||
}, [extLink, setQuote, getPost, fetchDid])
|
||||
}, [extLink, setQuote, getPost, fetchDid, getAgent])
|
||||
|
||||
return {extLink, setExtLink}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue