diff options
Diffstat (limited to 'src/lib/api/feed/following.ts')
-rw-r--r-- | src/lib/api/feed/following.ts | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/lib/api/feed/following.ts b/src/lib/api/feed/following.ts index f14807a57..13f06c7ab 100644 --- a/src/lib/api/feed/following.ts +++ b/src/lib/api/feed/following.ts @@ -1,30 +1,28 @@ -import {AppBskyFeedDefs} from '@atproto/api' -import {RootStoreModel} from 'state/index' +import {AppBskyFeedDefs, BskyAgent} from '@atproto/api' import {FeedAPI, FeedAPIResponse} from './types' export class FollowingFeedAPI implements FeedAPI { - cursor: string | undefined - - constructor(public rootStore: RootStoreModel) {} - - reset() { - this.cursor = undefined - } + constructor(public agent: BskyAgent) {} async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> { - const res = await this.rootStore.agent.getTimeline({ + const res = await this.agent.getTimeline({ limit: 1, }) return res.data.feed[0] } - async fetchNext({limit}: {limit: number}): Promise<FeedAPIResponse> { - const res = await this.rootStore.agent.getTimeline({ - cursor: this.cursor, + async fetch({ + cursor, + limit, + }: { + cursor: string | undefined + limit: number + }): Promise<FeedAPIResponse> { + const res = await this.agent.getTimeline({ + cursor, limit, }) if (res.success) { - this.cursor = res.data.cursor return { cursor: res.data.cursor, feed: res.data.feed, |