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
|
@ -3,7 +3,6 @@ import {View} from 'react-native'
|
|||
import {Image} from 'expo-image'
|
||||
import {
|
||||
AppBskyGraphDefs,
|
||||
AppBskyGraphGetList,
|
||||
AppBskyGraphStarterpack,
|
||||
AtUri,
|
||||
ModerationOpts,
|
||||
|
@ -14,11 +13,7 @@ import {msg, Trans} from '@lingui/macro'
|
|||
import {useLingui} from '@lingui/react'
|
||||
import {useNavigation} from '@react-navigation/native'
|
||||
import {NativeStackScreenProps} from '@react-navigation/native-stack'
|
||||
import {
|
||||
InfiniteData,
|
||||
UseInfiniteQueryResult,
|
||||
useQueryClient,
|
||||
} from '@tanstack/react-query'
|
||||
import {useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
import {cleanError} from '#/lib/strings/errors'
|
||||
import {logger} from '#/logger'
|
||||
|
@ -33,7 +28,6 @@ import {getStarterPackOgCard} from 'lib/strings/starter-pack'
|
|||
import {isWeb} from 'platform/detection'
|
||||
import {updateProfileShadow} from 'state/cache/profile-shadow'
|
||||
import {useModerationOpts} from 'state/preferences/moderation-opts'
|
||||
import {useListMembersQuery} from 'state/queries/list-members'
|
||||
import {useResolvedStarterPackShortLink} from 'state/queries/resolve-short-link'
|
||||
import {useResolveDidQuery} from 'state/queries/resolve-uri'
|
||||
import {useShortenLink} from 'state/queries/shorten-link'
|
||||
|
@ -123,7 +117,6 @@ export function StarterPackScreenInner({
|
|||
isLoading: isLoadingStarterPack,
|
||||
isError: isErrorStarterPack,
|
||||
} = useStarterPackQuery({did, rkey})
|
||||
const listMembersQuery = useListMembersQuery(starterPack?.list?.uri, 50)
|
||||
|
||||
const isValid =
|
||||
starterPack &&
|
||||
|
@ -134,12 +127,7 @@ export function StarterPackScreenInner({
|
|||
if (!did || !starterPack || !isValid || !moderationOpts) {
|
||||
return (
|
||||
<ListMaybePlaceholder
|
||||
isLoading={
|
||||
isLoadingDid ||
|
||||
isLoadingStarterPack ||
|
||||
listMembersQuery.isLoading ||
|
||||
!moderationOpts
|
||||
}
|
||||
isLoading={isLoadingDid || isLoadingStarterPack || !moderationOpts}
|
||||
isError={isErrorDid || isErrorStarterPack || !isValid}
|
||||
errorMessage={_(msg`That starter pack could not be found.`)}
|
||||
emptyMessage={_(msg`That starter pack could not be found.`)}
|
||||
|
@ -155,7 +143,6 @@ export function StarterPackScreenInner({
|
|||
<StarterPackScreenLoaded
|
||||
starterPack={starterPack}
|
||||
routeParams={routeParams}
|
||||
listMembersQuery={listMembersQuery}
|
||||
moderationOpts={moderationOpts}
|
||||
/>
|
||||
)
|
||||
|
@ -164,14 +151,10 @@ export function StarterPackScreenInner({
|
|||
function StarterPackScreenLoaded({
|
||||
starterPack,
|
||||
routeParams,
|
||||
listMembersQuery,
|
||||
moderationOpts,
|
||||
}: {
|
||||
starterPack: AppBskyGraphDefs.StarterPackView
|
||||
routeParams: StarterPackScreeProps['route']['params']
|
||||
listMembersQuery: UseInfiniteQueryResult<
|
||||
InfiniteData<AppBskyGraphGetList.OutputSchema>
|
||||
>
|
||||
moderationOpts: ModerationOpts
|
||||
}) {
|
||||
const showPeopleTab = Boolean(starterPack.list)
|
||||
|
@ -242,7 +225,6 @@ function StarterPackScreenLoaded({
|
|||
headerHeight={headerHeight}
|
||||
// @ts-expect-error
|
||||
scrollElRef={scrollElRef}
|
||||
listMembersQuery={listMembersQuery}
|
||||
moderationOpts={moderationOpts}
|
||||
/>
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue