diff --git a/src/components/StarterPack/StarterPackCard.tsx b/src/components/StarterPack/StarterPackCard.tsx index 22e0a155ab..72deca9f6b 100644 --- a/src/components/StarterPack/StarterPackCard.tsx +++ b/src/components/StarterPack/StarterPackCard.tsx @@ -1,7 +1,7 @@ import React from 'react' import {View} from 'react-native' import {Image} from 'expo-image' -import {AppBskyGraphDefs, AppBskyGraphStarterpack, AtUri} from '@atproto/api' +import {AppBskyGraphStarterpack, AtUri} from '@atproto/api' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useQueryClient} from '@tanstack/react-query' @@ -15,11 +15,12 @@ import {atoms as a, useTheme} from '#/alf' import {StarterPack} from '#/components/icons/StarterPack' import {Link as BaseLink, LinkProps as BaseLinkProps} from '#/components/Link' import {Text} from '#/components/Typography' +import * as atp from '#/types/atproto' export function Default({ starterPack, }: { - starterPack?: AppBskyGraphDefs.StarterPackViewBasic + starterPack?: atp.starterPack.AnyStarterPackView }) { if (!starterPack) return null return ( @@ -32,7 +33,7 @@ export function Default({ export function Notification({ starterPack, }: { - starterPack?: AppBskyGraphDefs.StarterPackViewBasic + starterPack?: atp.starterPack.AnyStarterPackView }) { if (!starterPack) return null return ( @@ -47,7 +48,7 @@ export function Card({ noIcon, noDescription, }: { - starterPack: AppBskyGraphDefs.StarterPackViewBasic + starterPack: atp.starterPack.AnyStarterPackView noIcon?: boolean noDescription?: boolean }) { @@ -57,7 +58,12 @@ export function Card({ const t = useTheme() const {currentAccount} = useSession() - if (!AppBskyGraphStarterpack.isRecord(record)) { + if ( + !atp.dangerousIsType( + record, + AppBskyGraphStarterpack.isRecord, + ) + ) { return null } @@ -100,7 +106,7 @@ export function Link({ starterPack, children, }: { - starterPack: AppBskyGraphDefs.StarterPackViewBasic + starterPack: atp.starterPack.AnyStarterPackView onPress?: () => void children: BaseLinkProps['children'] }) { @@ -139,7 +145,7 @@ export function Link({ export function Embed({ starterPack, }: { - starterPack: AppBskyGraphDefs.StarterPackViewBasic + starterPack: atp.starterPack.AnyStarterPackView }) { const t = useTheme() const imageUri = getStarterPackOgCard(starterPack) diff --git a/src/lib/strings/starter-pack.ts b/src/lib/strings/starter-pack.ts index ca34100155..2e4497a443 100644 --- a/src/lib/strings/starter-pack.ts +++ b/src/lib/strings/starter-pack.ts @@ -1,4 +1,6 @@ -import {AppBskyGraphDefs, AtUri} from '@atproto/api' +import {AtUri} from '@atproto/api' + +import * as atp from '#/types/atproto' export function createStarterPackLinkFromAndroidReferrer( referrerQueryString: string, @@ -79,7 +81,7 @@ export function httpStarterPackUriToAtUri(httpUri?: string): string | null { } export function getStarterPackOgCard( - didOrStarterPack: AppBskyGraphDefs.StarterPackView | string, + didOrStarterPack: atp.starterPack.AnyStarterPackView | string, rkey?: string, ) { if (typeof didOrStarterPack === 'string') { diff --git a/src/types/atproto/index.ts b/src/types/atproto/index.ts index 18db966ac8..ee24ab1e3d 100644 --- a/src/types/atproto/index.ts +++ b/src/types/atproto/index.ts @@ -1,4 +1,5 @@ export * as profile from '#/types/atproto/profile' +export * as starterPack from '#/types/atproto/starterPack' /** * Use sparingly, and only when you know it's safe to do so. diff --git a/src/types/atproto/starterPack.ts b/src/types/atproto/starterPack.ts new file mode 100644 index 0000000000..513b4750bd --- /dev/null +++ b/src/types/atproto/starterPack.ts @@ -0,0 +1,21 @@ +import {AppBskyGraphDefs} from '@atproto/api' + +export { + /** + * Renamed to clarify source of this util, but directly aliases the original. + * {@link AppBskyGraphDefs.isStarterPackViewBasic} + */ + isStarterPackViewBasic as isBasicView, + /** + * Renamed to clarify source of this util, but directly aliases the original. + * {@link AppBskyGraphDefs.isStarterPackView} + */ + isStarterPackView as isView, +} from '@atproto/api/dist/client/types/app/bsky/graph/defs' + +/** + * Matches any starter pack view exported by our SDK + */ +export type AnyStarterPackView = + | AppBskyGraphDefs.StarterPackViewBasic + | AppBskyGraphDefs.StarterPackView