Files
bsky-social-app/src/lib/api/feed/list.ts
T
Samuel Newman 2696104e6d survive session-bundle rebuild in chat, feeds, prefs, and age assurance
Review fixes (PR #11182 round 2). Client identity is no longer stable
across token refresh - on web, a cross-tab sync rebuilds the bundle and
disposes the old clients (whose fetch now throws) - so anything that
captured a client at construction time must re-point at the live one:

- MessagesEventBus and Convo get updateClient(); providers sync it via
  effect. No remount, so poll cursors and optimistic pendingMessages
  survive.
- FeedAPI implementations get setClient(); the post-feed queryFn and
  pollLatest re-point page-held apis before fetching (Merge/Home apis
  are stateful across pages, so they cannot be rebuilt per fetch).
- usePreferencesQuery applies fetched labeler dids to the live appview
  client (applyLabelersToClient, factored from session/moderation),
  restoring the old BskyAgent.getPreferences header side effect.
- ageAssurance redirect overlay/dialog polling is mount-only with
  render-synced refs; a client swap mid-poll no longer latches the
  unmounted flag and strands the overlay.
- Convo message-failure classification defers to lex's shouldRetry()
  instead of treating all status-less errors as recoverable.

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

51 lines
1.0 KiB
TypeScript

import {type Client} from '@atproto/lex-client'
import {app} from '#/lexicons'
import {type FeedAPI, type FeedAPIResponse} from './types'
export class ListFeedAPI implements FeedAPI {
client: Client
params: app.bsky.feed.getListFeed.$Params
constructor({
client,
feedParams,
}: {
client: Client
feedParams: app.bsky.feed.getListFeed.$Params
}) {
this.client = client
this.params = feedParams
}
setClient(client: Client) {
this.client = client
}
async peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost> {
const res = await this.client.call(app.bsky.feed.getListFeed, {
...this.params,
limit: 1,
})
return res.feed[0]
}
async fetch({
cursor,
limit,
}: {
cursor: string | undefined
limit: number
}): Promise<FeedAPIResponse> {
const res = await this.client.call(app.bsky.feed.getListFeed, {
...this.params,
cursor,
limit,
})
return {
cursor: res.cursor,
feed: res.feed,
}
}
}