diff options
Diffstat (limited to 'src/lib/api/feed/list.ts')
-rw-r--r-- | src/lib/api/feed/list.ts | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/lib/api/feed/list.ts b/src/lib/api/feed/list.ts index e58494675..6cb0730e7 100644 --- a/src/lib/api/feed/list.ts +++ b/src/lib/api/feed/list.ts @@ -1,38 +1,37 @@ import { AppBskyFeedDefs, AppBskyFeedGetListFeed as GetListFeed, + BskyAgent, } from '@atproto/api' -import {RootStoreModel} from 'state/index' import {FeedAPI, FeedAPIResponse} from './types' export class ListFeedAPI implements FeedAPI { - cursor: string | undefined - constructor( - public rootStore: RootStoreModel, + public agent: BskyAgent, public params: GetListFeed.QueryParams, ) {} - reset() { - this.cursor = undefined - } - async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> { - const res = await this.rootStore.agent.app.bsky.feed.getListFeed({ + const res = await this.agent.app.bsky.feed.getListFeed({ ...this.params, limit: 1, }) return res.data.feed[0] } - async fetchNext({limit}: {limit: number}): Promise<FeedAPIResponse> { - const res = await this.rootStore.agent.app.bsky.feed.getListFeed({ + async fetch({ + cursor, + limit, + }: { + cursor: string | undefined + limit: number + }): Promise<FeedAPIResponse> { + const res = await this.agent.app.bsky.feed.getListFeed({ ...this.params, - cursor: this.cursor, + cursor, limit, }) if (res.success) { - this.cursor = res.data.cursor return { cursor: res.data.cursor, feed: res.data.feed, |