Add starter pack embeds to posts (#4699)
* starter pack embeds * revert test code * Types * add `BaseLink` * precache on click * rm log * add a comment * loading state * top margin --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
This commit is contained in:
parent
a3d4fb652b
commit
aa7117edb6
10 changed files with 246 additions and 41 deletions
|
@ -10,6 +10,7 @@ import {
|
|||
getFeedAsEmbed,
|
||||
getListAsEmbed,
|
||||
getPostAsQuote,
|
||||
getStarterPackAsEmbed,
|
||||
} from 'lib/link-meta/bsky'
|
||||
import {getLinkMeta} from 'lib/link-meta/link-meta'
|
||||
import {resolveShortLink} from 'lib/link-meta/resolve-short-link'
|
||||
|
@ -18,6 +19,8 @@ import {
|
|||
isBskyCustomFeedUrl,
|
||||
isBskyListUrl,
|
||||
isBskyPostUrl,
|
||||
isBskyStarterPackUrl,
|
||||
isBskyStartUrl,
|
||||
isShortLink,
|
||||
} from 'lib/strings/url-helpers'
|
||||
import {ImageModel} from 'state/models/media/image'
|
||||
|
@ -96,6 +99,23 @@ export function useExternalLinkFetch({
|
|||
setExtLink(undefined)
|
||||
},
|
||||
)
|
||||
} else if (
|
||||
isBskyStartUrl(extLink.uri) ||
|
||||
isBskyStarterPackUrl(extLink.uri)
|
||||
) {
|
||||
getStarterPackAsEmbed(agent, fetchDid, extLink.uri).then(
|
||||
({embed, meta}) => {
|
||||
if (aborted) {
|
||||
return
|
||||
}
|
||||
setExtLink({
|
||||
uri: extLink.uri,
|
||||
isLoading: false,
|
||||
meta,
|
||||
embed,
|
||||
})
|
||||
},
|
||||
)
|
||||
} else if (isShortLink(extLink.uri)) {
|
||||
if (isShortLink(extLink.uri)) {
|
||||
resolveShortLink(extLink.uri).then(res => {
|
||||
|
|
|
@ -30,6 +30,7 @@ import {ListEmbed} from './ListEmbed'
|
|||
import {MaybeQuoteEmbed} from './QuoteEmbed'
|
||||
import hairlineWidth = StyleSheet.hairlineWidth
|
||||
import {useLargeAltBadgeEnabled} from '#/state/preferences/large-alt-badge'
|
||||
import {Embed as StarterPackCard} from '#/components/StarterPack/StarterPackCard'
|
||||
|
||||
type Embed =
|
||||
| AppBskyEmbedRecord.View
|
||||
|
@ -90,6 +91,10 @@ export function PostEmbeds({
|
|||
return <ListEmbed item={embed.record} />
|
||||
}
|
||||
|
||||
if (AppBskyGraphDefs.isStarterPackViewBasic(embed.record)) {
|
||||
return <StarterPackCard starterPack={embed.record} />
|
||||
}
|
||||
|
||||
// quote post
|
||||
// =
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue