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:
Hailey 2024-07-03 18:15:08 -07:00 committed by GitHub
parent a3d4fb652b
commit aa7117edb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 246 additions and 41 deletions

View file

@ -347,3 +347,36 @@ async function whenAppViewReady(
() => agent.app.bsky.graph.getStarterPack({starterPack: uri}),
)
}
export async function precacheStarterPack(
queryClient: QueryClient,
starterPack:
| AppBskyGraphDefs.StarterPackViewBasic
| AppBskyGraphDefs.StarterPackView,
) {
if (!AppBskyGraphStarterpack.isRecord(starterPack.record)) {
return
}
let starterPackView: AppBskyGraphDefs.StarterPackView | undefined
if (AppBskyGraphDefs.isStarterPackView(starterPack)) {
starterPackView = starterPack
} else if (AppBskyGraphDefs.isStarterPackViewBasic(starterPack)) {
const listView: AppBskyGraphDefs.ListViewBasic = {
uri: starterPack.record.list,
// This will be populated once the data from server is fetched
cid: '',
name: starterPack.record.name,
purpose: 'app.bsky.graph.defs#referencelist',
}
starterPackView = {
...starterPack,
$type: 'app.bsky.graph.defs#starterPackView',
list: listView,
}
}
if (starterPackView) {
queryClient.setQueryData(RQKEY({uri: starterPack.uri}), starterPackView)
}
}