Add AnyStarterPackView and related, implement in first usage
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {Image} from 'expo-image'
|
import {Image} from 'expo-image'
|
||||||
import {AppBskyGraphDefs, AppBskyGraphStarterpack, AtUri} from '@atproto/api'
|
import {AppBskyGraphStarterpack, AtUri} from '@atproto/api'
|
||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
@@ -15,11 +15,12 @@ import {atoms as a, useTheme} from '#/alf'
|
|||||||
import {StarterPack} from '#/components/icons/StarterPack'
|
import {StarterPack} from '#/components/icons/StarterPack'
|
||||||
import {Link as BaseLink, LinkProps as BaseLinkProps} from '#/components/Link'
|
import {Link as BaseLink, LinkProps as BaseLinkProps} from '#/components/Link'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import * as atp from '#/types/atproto'
|
||||||
|
|
||||||
export function Default({
|
export function Default({
|
||||||
starterPack,
|
starterPack,
|
||||||
}: {
|
}: {
|
||||||
starterPack?: AppBskyGraphDefs.StarterPackViewBasic
|
starterPack?: atp.starterPack.AnyStarterPackView
|
||||||
}) {
|
}) {
|
||||||
if (!starterPack) return null
|
if (!starterPack) return null
|
||||||
return (
|
return (
|
||||||
@@ -32,7 +33,7 @@ export function Default({
|
|||||||
export function Notification({
|
export function Notification({
|
||||||
starterPack,
|
starterPack,
|
||||||
}: {
|
}: {
|
||||||
starterPack?: AppBskyGraphDefs.StarterPackViewBasic
|
starterPack?: atp.starterPack.AnyStarterPackView
|
||||||
}) {
|
}) {
|
||||||
if (!starterPack) return null
|
if (!starterPack) return null
|
||||||
return (
|
return (
|
||||||
@@ -47,7 +48,7 @@ export function Card({
|
|||||||
noIcon,
|
noIcon,
|
||||||
noDescription,
|
noDescription,
|
||||||
}: {
|
}: {
|
||||||
starterPack: AppBskyGraphDefs.StarterPackViewBasic
|
starterPack: atp.starterPack.AnyStarterPackView
|
||||||
noIcon?: boolean
|
noIcon?: boolean
|
||||||
noDescription?: boolean
|
noDescription?: boolean
|
||||||
}) {
|
}) {
|
||||||
@@ -57,7 +58,12 @@ export function Card({
|
|||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
|
||||||
if (!AppBskyGraphStarterpack.isRecord(record)) {
|
if (
|
||||||
|
!atp.dangerousIsType<AppBskyGraphStarterpack.Record>(
|
||||||
|
record,
|
||||||
|
AppBskyGraphStarterpack.isRecord,
|
||||||
|
)
|
||||||
|
) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +106,7 @@ export function Link({
|
|||||||
starterPack,
|
starterPack,
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
starterPack: AppBskyGraphDefs.StarterPackViewBasic
|
starterPack: atp.starterPack.AnyStarterPackView
|
||||||
onPress?: () => void
|
onPress?: () => void
|
||||||
children: BaseLinkProps['children']
|
children: BaseLinkProps['children']
|
||||||
}) {
|
}) {
|
||||||
@@ -139,7 +145,7 @@ export function Link({
|
|||||||
export function Embed({
|
export function Embed({
|
||||||
starterPack,
|
starterPack,
|
||||||
}: {
|
}: {
|
||||||
starterPack: AppBskyGraphDefs.StarterPackViewBasic
|
starterPack: atp.starterPack.AnyStarterPackView
|
||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const imageUri = getStarterPackOgCard(starterPack)
|
const imageUri = getStarterPackOgCard(starterPack)
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {AppBskyGraphDefs, AtUri} from '@atproto/api'
|
import {AtUri} from '@atproto/api'
|
||||||
|
|
||||||
|
import * as atp from '#/types/atproto'
|
||||||
|
|
||||||
export function createStarterPackLinkFromAndroidReferrer(
|
export function createStarterPackLinkFromAndroidReferrer(
|
||||||
referrerQueryString: string,
|
referrerQueryString: string,
|
||||||
@@ -79,7 +81,7 @@ export function httpStarterPackUriToAtUri(httpUri?: string): string | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getStarterPackOgCard(
|
export function getStarterPackOgCard(
|
||||||
didOrStarterPack: AppBskyGraphDefs.StarterPackView | string,
|
didOrStarterPack: atp.starterPack.AnyStarterPackView | string,
|
||||||
rkey?: string,
|
rkey?: string,
|
||||||
) {
|
) {
|
||||||
if (typeof didOrStarterPack === 'string') {
|
if (typeof didOrStarterPack === 'string') {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export * as profile from '#/types/atproto/profile'
|
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.
|
* Use sparingly, and only when you know it's safe to do so.
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user