diff options
author | dan <dan.abramov@gmail.com> | 2024-10-08 09:02:58 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-07 17:02:58 -0700 |
commit | c06040cc209338fc37980648b31d4d64cc0c5c09 (patch) | |
tree | 766e41a310b03bed2e927f468114ca8d14602e5f /src/view/com/composer/useExternalLinkFetch.e2e.ts | |
parent | dd8be2e939d2879e2bb23b2ccd843a034d19b8dd (diff) | |
download | voidsky-c06040cc209338fc37980648b31d4d64cc0c5c09.tar.zst |
Fetch link previews from RQ (#5608)
Co-authored-by: Mary <git@mary.my.id> Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'src/view/com/composer/useExternalLinkFetch.e2e.ts')
-rw-r--r-- | src/view/com/composer/useExternalLinkFetch.e2e.ts | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/view/com/composer/useExternalLinkFetch.e2e.ts b/src/view/com/composer/useExternalLinkFetch.e2e.ts deleted file mode 100644 index 257a3e8e5..000000000 --- a/src/view/com/composer/useExternalLinkFetch.e2e.ts +++ /dev/null @@ -1,47 +0,0 @@ -import {useEffect, useState} from 'react' - -import {useAgent} from '#/state/session' -import * as apilib from 'lib/api/index' -import {getLinkMeta} from 'lib/link-meta/link-meta' -import {ComposerOpts} from 'state/shell/composer' - -export function useExternalLinkFetch({}: { - setQuote: (opts: ComposerOpts['quote']) => void -}) { - const agent = useAgent() - const [extLink, setExtLink] = useState<apilib.ExternalEmbedDraft | undefined>( - undefined, - ) - - useEffect(() => { - let aborted = false - const cleanup = () => { - aborted = true - } - if (!extLink) { - return cleanup - } - if (!extLink.meta) { - getLinkMeta(agent, extLink.uri).then(meta => { - if (aborted) { - return - } - setExtLink({ - uri: extLink.uri, - isLoading: !!meta.image, - meta, - }) - }) - return cleanup - } - if (extLink.isLoading) { - setExtLink({ - ...extLink, - isLoading: false, // done - }) - } - return cleanup - }, [extLink, agent]) - - return {extLink, setExtLink} -} |