[SDK] Remove @atproto/api (#11386)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import {View} from 'react-native'
|
||||
import {type AppBskyFeedDefs, AtUri} from '@atproto/api'
|
||||
import {AtUri} from '@atproto/syntax'
|
||||
import {moderateProfile} from '@bsky.app/sdk/moderation'
|
||||
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {moderateProfile} from '#/lib/moderation/subjects'
|
||||
import {makeProfileLink} from '#/lib/routes/links'
|
||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||
@@ -15,6 +15,7 @@ import {useFormatPostStatCount} from '#/components/PostControls/util'
|
||||
import {ProfileHoverCard} from '#/components/ProfileHoverCard'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {type app} from '#/lexicons'
|
||||
|
||||
const AVI_SIZE = 20
|
||||
|
||||
@@ -22,7 +23,7 @@ const AVI_SIZE = 20
|
||||
* The plain "N likes" stat for the expanded anchor post, linking to the likes
|
||||
* list. Renders nothing when the post has no likes.
|
||||
*/
|
||||
export function LikesStat({post}: {post: AppBskyFeedDefs.PostView}) {
|
||||
export function LikesStat({post}: {post: app.bsky.feed.defs.PostView}) {
|
||||
const t = useTheme()
|
||||
const {t: l} = useLingui()
|
||||
const formatPostStatCount = useFormatPostStatCount()
|
||||
@@ -62,7 +63,7 @@ export function LikesStat({post}: {post: AppBskyFeedDefs.PostView}) {
|
||||
* likes, the API max per page), so they are a sample of the most recent
|
||||
* likers, not an exhaustive list.
|
||||
*/
|
||||
export function KnownLikers({post}: {post: AppBskyFeedDefs.PostView}) {
|
||||
export function KnownLikers({post}: {post: app.bsky.feed.defs.PostView}) {
|
||||
const t = useTheme()
|
||||
const {t: l} = useLingui()
|
||||
const {hasSession, currentAccount} = useSession()
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import {memo, useMemo} from 'react'
|
||||
import {Text as RNText, View} from 'react-native'
|
||||
import {
|
||||
AppBskyFeedDefs,
|
||||
AppBskyFeedPost,
|
||||
type AppBskyFeedThreadgate,
|
||||
AtUri,
|
||||
} from '@atproto/api'
|
||||
import {AtUri} from '@atproto/syntax'
|
||||
import {RichText as RichTextAPI} from '@bsky.app/sdk/richtext'
|
||||
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
||||
|
||||
@@ -14,7 +9,6 @@ import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
||||
import {makeProfileLink} from '#/lib/routes/links'
|
||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||
import {asSdkFacets} from '#/lib/strings/rich-text-helpers'
|
||||
import {niceDate} from '#/lib/strings/time'
|
||||
import {
|
||||
POST_TOMBSTONE,
|
||||
@@ -65,6 +59,7 @@ import {Text} from '#/components/Typography'
|
||||
import {WhoCanReply} from '#/components/WhoCanReply'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {useActorStatus} from '#/features/liveNow'
|
||||
import {app} from '#/lexicons'
|
||||
import * as bsky from '#/types/bsky'
|
||||
|
||||
export function ThreadItemAnchor({
|
||||
@@ -75,7 +70,7 @@ export function ThreadItemAnchor({
|
||||
}: {
|
||||
item: Extract<ThreadItem, {type: 'threadPost'}>
|
||||
onPostSuccess?: (data: OnPostSuccessData) => void
|
||||
threadgateRecord?: AppBskyFeedThreadgate.Record
|
||||
threadgateRecord?: app.bsky.feed.threadgate.Main
|
||||
postSource?: PostSource
|
||||
}) {
|
||||
const postShadow = usePostShadow(item.value.post)
|
||||
@@ -176,9 +171,9 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({
|
||||
}: {
|
||||
item: Extract<ThreadItem, {type: 'threadPost'}>
|
||||
isRoot: boolean
|
||||
postShadow: Shadow<AppBskyFeedDefs.PostView>
|
||||
postShadow: Shadow<app.bsky.feed.defs.PostView>
|
||||
onPostSuccess?: (data: OnPostSuccessData) => void
|
||||
threadgateRecord?: AppBskyFeedThreadgate.Record
|
||||
threadgateRecord?: app.bsky.feed.threadgate.Main
|
||||
postSource?: PostSource
|
||||
}) {
|
||||
const t = useTheme()
|
||||
@@ -200,7 +195,7 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({
|
||||
() =>
|
||||
new RichTextAPI({
|
||||
text: record.text,
|
||||
facets: asSdkFacets(record.facets),
|
||||
facets: record.facets,
|
||||
}),
|
||||
[record],
|
||||
)
|
||||
@@ -244,7 +239,11 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({
|
||||
const viaRepost = useMemo(() => {
|
||||
const reason = postSource?.post.reason
|
||||
|
||||
if (AppBskyFeedDefs.isReasonRepost(reason) && reason.uri && reason.cid) {
|
||||
if (
|
||||
bsky.isType(app.bsky.feed.defs.reasonRepost, reason) &&
|
||||
reason.uri &&
|
||||
reason.cid
|
||||
) {
|
||||
return {
|
||||
uri: reason.uri,
|
||||
cid: reason.cid,
|
||||
@@ -574,16 +573,13 @@ function ExpandedPostDetails({
|
||||
)
|
||||
}
|
||||
|
||||
function BackdatedPostIndicator({post}: {post: AppBskyFeedDefs.PostView}) {
|
||||
function BackdatedPostIndicator({post}: {post: app.bsky.feed.defs.PostView}) {
|
||||
const t = useTheme()
|
||||
const {t: l, i18n} = useLingui()
|
||||
const control = Prompt.usePromptControl()
|
||||
|
||||
const indexedAt = new Date(post.indexedAt)
|
||||
const createdAt = bsky.dangerousIsType<AppBskyFeedPost.Record>(
|
||||
post.record,
|
||||
AppBskyFeedPost.isRecord,
|
||||
)
|
||||
const createdAt = bsky.isType(app.bsky.feed.post, post.record)
|
||||
? new Date(post.record.createdAt)
|
||||
: new Date(post.indexedAt)
|
||||
|
||||
@@ -664,8 +660,8 @@ function BackdatedPostIndicator({post}: {post: AppBskyFeedDefs.PostView}) {
|
||||
}
|
||||
|
||||
function getThreadAuthor(
|
||||
post: AppBskyFeedDefs.PostView,
|
||||
record: AppBskyFeedPost.Record,
|
||||
post: app.bsky.feed.defs.PostView,
|
||||
record: app.bsky.feed.post.Main,
|
||||
): string {
|
||||
if (!record.reply) {
|
||||
return post.author.did
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {useCallback, useEffect, useMemo, useState} from 'react'
|
||||
import {type AppBskyActorDefs} from '@atproto/api'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
@@ -18,6 +17,7 @@ import {Check_Stroke2_Corner0_Rounded as CheckIcon} from '#/components/icons/Che
|
||||
import {PlusLarge_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/Plus'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {IS_IOS} from '#/env'
|
||||
import {type app} from '#/lexicons'
|
||||
import {GrowthHack} from './GrowthHack'
|
||||
|
||||
export function ThreadItemAnchorFollowButton({
|
||||
@@ -57,7 +57,7 @@ export function ThreadItemAnchorFollowButtonInner({
|
||||
function PostThreadFollowBtnLoaded({
|
||||
profile: profileUnshadowed,
|
||||
}: {
|
||||
profile: AppBskyActorDefs.ProfileViewDetailed
|
||||
profile: app.bsky.actor.defs.ProfileViewDetailed
|
||||
}) {
|
||||
const navigation = useNavigation()
|
||||
const {_} = useLingui()
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import {memo, type ReactNode, useCallback, useMemo, useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {
|
||||
type AppBskyFeedDefs,
|
||||
type AppBskyFeedThreadgate,
|
||||
AtUri,
|
||||
} from '@atproto/api'
|
||||
import {AtUri} from '@atproto/syntax'
|
||||
import {RichText as RichTextAPI} from '@bsky.app/sdk/richtext'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
|
||||
@@ -12,7 +8,6 @@ import {MAX_POST_LINES} from '#/lib/constants'
|
||||
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
||||
import {makeProfileLink} from '#/lib/routes/links'
|
||||
import {countLines} from '#/lib/strings/helpers'
|
||||
import {asSdkFacets} from '#/lib/strings/rich-text-helpers'
|
||||
import {
|
||||
POST_TOMBSTONE,
|
||||
type Shadow,
|
||||
@@ -55,6 +50,7 @@ import * as Skele from '#/components/Skeleton'
|
||||
import {SubtleHover} from '#/components/SubtleHover'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {useActorStatus} from '#/features/liveNow'
|
||||
import {type app} from '#/lexicons'
|
||||
|
||||
export type ThreadItemPostProps = {
|
||||
item: Extract<ThreadItem, {type: 'threadPost'}>
|
||||
@@ -63,7 +59,7 @@ export type ThreadItemPostProps = {
|
||||
topBorder?: boolean
|
||||
}
|
||||
onPostSuccess?: (data: OnPostSuccessData) => void
|
||||
threadgateRecord?: AppBskyFeedThreadgate.Record
|
||||
threadgateRecord?: app.bsky.feed.threadgate.Main
|
||||
}
|
||||
|
||||
export function ThreadItemPost({
|
||||
@@ -197,7 +193,7 @@ const ThreadItemPostInner = memo(function ThreadItemPostInner({
|
||||
onPostSuccess,
|
||||
threadgateRecord,
|
||||
}: ThreadItemPostProps & {
|
||||
postShadow: Shadow<AppBskyFeedDefs.PostView>
|
||||
postShadow: Shadow<app.bsky.feed.defs.PostView>
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const {openComposer} = useOpenComposer()
|
||||
@@ -212,7 +208,7 @@ const ThreadItemPostInner = memo(function ThreadItemPostInner({
|
||||
() =>
|
||||
new RichTextAPI({
|
||||
text: record.text,
|
||||
facets: asSdkFacets(record.facets),
|
||||
facets: record.facets,
|
||||
}),
|
||||
[record],
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {Text, View} from 'react-native'
|
||||
import {type AppBskyUnspeccedDefs} from '@atproto/api'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {atoms as a, ios, platform, useTheme} from '#/alf'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {type app} from '#/lexicons'
|
||||
|
||||
/**
|
||||
* How far the inline badge is nudged below the text baseline. Android's
|
||||
@@ -12,7 +12,7 @@ import {useAnalytics} from '#/analytics'
|
||||
export const POST_NUMBER_INLINE_OFFSET = 6
|
||||
|
||||
export function useHasThreadItemPostNumber(
|
||||
value: AppBskyUnspeccedDefs.ThreadItemPost,
|
||||
value: app.bsky.unspecced.defs.ThreadItemPost,
|
||||
) {
|
||||
const ax = useAnalytics()
|
||||
const index = value.opThreadPostIndex
|
||||
@@ -32,7 +32,7 @@ export function ThreadItemPostNumber({
|
||||
value,
|
||||
inline = true,
|
||||
}: {
|
||||
value: AppBskyUnspeccedDefs.ThreadItemPost
|
||||
value: app.bsky.unspecced.defs.ThreadItemPost
|
||||
inline?: boolean
|
||||
}) {
|
||||
const t = useTheme()
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import {memo, useCallback, useMemo, useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {
|
||||
type AppBskyFeedDefs,
|
||||
type AppBskyFeedThreadgate,
|
||||
AtUri,
|
||||
} from '@atproto/api'
|
||||
import {AtUri} from '@atproto/syntax'
|
||||
import {RichText as RichTextAPI} from '@bsky.app/sdk/richtext'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
|
||||
@@ -12,7 +8,6 @@ import {MAX_POST_LINES} from '#/lib/constants'
|
||||
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
||||
import {makeProfileLink} from '#/lib/routes/links'
|
||||
import {countLines} from '#/lib/strings/helpers'
|
||||
import {asSdkFacets} from '#/lib/strings/rich-text-helpers'
|
||||
import {
|
||||
POST_TOMBSTONE,
|
||||
type Shadow,
|
||||
@@ -51,6 +46,7 @@ import {RichText} from '#/components/RichText'
|
||||
import * as Skele from '#/components/Skeleton'
|
||||
import {SubtleHover} from '#/components/SubtleHover'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {type app} from '#/lexicons'
|
||||
|
||||
/**
|
||||
* Mimic the space in PostMeta
|
||||
@@ -69,7 +65,7 @@ export function ThreadItemTreePost({
|
||||
topBorder?: boolean
|
||||
}
|
||||
onPostSuccess?: (data: OnPostSuccessData) => void
|
||||
threadgateRecord?: AppBskyFeedThreadgate.Record
|
||||
threadgateRecord?: app.bsky.feed.threadgate.Main
|
||||
}) {
|
||||
const postShadow = usePostShadow(item.value.post)
|
||||
|
||||
@@ -252,13 +248,13 @@ const ThreadItemTreePostInner = memo(function ThreadItemTreePostInner({
|
||||
threadgateRecord,
|
||||
}: {
|
||||
item: Extract<ThreadItem, {type: 'threadPost'}>
|
||||
postShadow: Shadow<AppBskyFeedDefs.PostView>
|
||||
postShadow: Shadow<app.bsky.feed.defs.PostView>
|
||||
overrides?: {
|
||||
moderation?: boolean
|
||||
topBorder?: boolean
|
||||
}
|
||||
onPostSuccess?: (data: OnPostSuccessData) => void
|
||||
threadgateRecord?: AppBskyFeedThreadgate.Record
|
||||
threadgateRecord?: app.bsky.feed.threadgate.Main
|
||||
}): React.ReactNode {
|
||||
const {openComposer} = useOpenComposer()
|
||||
const {currentAccount} = useSession()
|
||||
@@ -272,7 +268,7 @@ const ThreadItemTreePostInner = memo(function ThreadItemTreePostInner({
|
||||
() =>
|
||||
new RichTextAPI({
|
||||
text: record.text,
|
||||
facets: asSdkFacets(record.facets),
|
||||
facets: record.facets,
|
||||
}),
|
||||
[record],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user