about summary refs log tree commit diff
path: root/src/lib/api/feed/author.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/api/feed/author.ts')
-rw-r--r--src/lib/api/feed/author.ts28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/lib/api/feed/author.ts b/src/lib/api/feed/author.ts
index ec8795e1a..92df84f8b 100644
--- a/src/lib/api/feed/author.ts
+++ b/src/lib/api/feed/author.ts
@@ -2,37 +2,33 @@ import {
   AppBskyFeedDefs,
   AppBskyFeedGetAuthorFeed as GetAuthorFeed,
 } from '@atproto/api'
-import {RootStoreModel} from 'state/index'
 import {FeedAPI, FeedAPIResponse} from './types'
+import {getAgent} from '#/state/session'
 
 export class AuthorFeedAPI implements FeedAPI {
-  cursor: string | undefined
-
-  constructor(
-    public rootStore: RootStoreModel,
-    public params: GetAuthorFeed.QueryParams,
-  ) {}
-
-  reset() {
-    this.cursor = undefined
-  }
+  constructor(public params: GetAuthorFeed.QueryParams) {}
 
   async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
-    const res = await this.rootStore.agent.getAuthorFeed({
+    const res = await getAgent().getAuthorFeed({
       ...this.params,
       limit: 1,
     })
     return res.data.feed[0]
   }
 
-  async fetchNext({limit}: {limit: number}): Promise<FeedAPIResponse> {
-    const res = await this.rootStore.agent.getAuthorFeed({
+  async fetch({
+    cursor,
+    limit,
+  }: {
+    cursor: string | undefined
+    limit: number
+  }): Promise<FeedAPIResponse> {
+    const res = await getAgent().getAuthorFeed({
       ...this.params,
-      cursor: this.cursor,
+      cursor,
       limit,
     })
     if (res.success) {
-      this.cursor = res.data.cursor
       return {
         cursor: res.data.cursor,
         feed: this._filter(res.data.feed),