import {type Client, type XrpcRequestParams} from '@atproto/lex' import {app} from '#/lexicons' import {type FeedAPI, type FeedAPIResponse} from './types' type GetListFeedParams = XrpcRequestParams< typeof app.bsky.feed.getListFeed.main > export class ListFeedAPI implements FeedAPI { client: Client params: GetListFeedParams constructor({ client, feedParams, }: { client: Client feedParams: GetListFeedParams }) { this.client = client this.params = feedParams } async peekLatest(): Promise { const data = await this.client.call(app.bsky.feed.getListFeed, { ...this.params, limit: 1, }) return data.feed[0] } async fetch({ cursor, limit, }: { cursor: string | undefined limit: number }): Promise { /* * A failed request rejects rather than resolving, so the error propagates * to the query and drives the feed error UI. The agent behaved the same * way - its `success` flag was only ever true - so the empty-page branch * this replaces was unreachable. */ const data = await this.client.call(app.bsky.feed.getListFeed, { ...this.params, cursor, limit, }) return { cursor: data.cursor, feed: data.feed, } } }