Files
bsky-social-app/src/lib/api/feed/posts.ts
T
Samuel Newman 300a50b69a migrate runtime call sites to lex clients and sdk actions
Phase 3 tasks 3-7 (parallel wave): composer/post pipeline on
pdsClient/appviewClient with structural+instance blob guards and a golden
CID fixture test; chat Convo/EventBus/queries on the dedicated chat client;
preferences sugar to SDK actions on the PDS client; remaining state/queries
producers (usePostThread unspecced flip, video scoped-token clients,
notifications, starter packs, lists) to client.call; UI runtime sweep
(AtUri from @atproto/syntax, moderation fns from @bsky.app/sdk/moderation,
SDK RichText, ozone reason tokens, guard rewrites via #/types/bsky).

Intermediate checkpoint (hooks skipped): ~114 typecheck errors remain in
cross-boundary consumer files, resolved by the type-only codemod next.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-30 18:12:10 +03:00

45 lines
1.1 KiB
TypeScript

import {type Client} from '@atproto/lex-client'
import {logger} from '#/logger'
import {app} from '#/lexicons'
import {type FeedAPI, type FeedAPIResponse} from './types'
export class PostListFeedAPI implements FeedAPI {
client: Client
params: app.bsky.feed.getPosts.$Params
peek: app.bsky.feed.defs.FeedViewPost | null = null
constructor({
client,
feedParams,
}: {
client: Client
feedParams: app.bsky.feed.getPosts.$Params
}) {
this.client = client
if (feedParams.uris.length > 25) {
logger.warn(
`Too many URIs provided - expected 25, got ${feedParams.uris.length}`,
)
}
this.params = {
uris: feedParams.uris.slice(0, 25),
}
}
async peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost> {
if (this.peek) return this.peek
throw new Error('Has not fetched yet')
}
async fetch({}: {}): Promise<FeedAPIResponse> {
const res = await this.client.call(app.bsky.feed.getPosts, {
...this.params,
})
this.peek = {post: res.posts[0]}
return {
feed: res.posts.map(post => ({post})),
}
}
}