about summary refs log tree commit diff
path: root/src/lib/api/feed/author.ts
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2024-04-25 15:29:06 -0500
committerGitHub <noreply@github.com>2024-04-25 21:29:06 +0100
commitec376960347a6255f1ec12c1758797ac30c073ff (patch)
tree69676999d62dd48d9150c2ed4d1bb3febc822ba5 /src/lib/api/feed/author.ts
parent282ad4b17d7cfde9ae4743a0f909124dfc309960 (diff)
downloadvoidsky-ec376960347a6255f1ec12c1758797ac30c073ff.tar.zst
[Session] Drill `getAgent` into feed APIs (#3701)
* Update to desired post-feed usage

* Drill agent into feed apis

* Thread getAgent instead

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src/lib/api/feed/author.ts')
-rw-r--r--src/lib/api/feed/author.ts21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/lib/api/feed/author.ts b/src/lib/api/feed/author.ts
index 57db061b3..85601d068 100644
--- a/src/lib/api/feed/author.ts
+++ b/src/lib/api/feed/author.ts
@@ -1,15 +1,28 @@
 import {
   AppBskyFeedDefs,
   AppBskyFeedGetAuthorFeed as GetAuthorFeed,
+  BskyAgent,
 } from '@atproto/api'
+
 import {FeedAPI, FeedAPIResponse} from './types'
-import {getAgent} from '#/state/session'
 
 export class AuthorFeedAPI implements FeedAPI {
-  constructor(public params: GetAuthorFeed.QueryParams) {}
+  getAgent: () => BskyAgent
+  params: GetAuthorFeed.QueryParams
+
+  constructor({
+    getAgent,
+    feedParams,
+  }: {
+    getAgent: () => BskyAgent
+    feedParams: GetAuthorFeed.QueryParams
+  }) {
+    this.getAgent = getAgent
+    this.params = feedParams
+  }
 
   async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
-    const res = await getAgent().getAuthorFeed({
+    const res = await this.getAgent().getAuthorFeed({
       ...this.params,
       limit: 1,
     })
@@ -23,7 +36,7 @@ export class AuthorFeedAPI implements FeedAPI {
     cursor: string | undefined
     limit: number
   }): Promise<FeedAPIResponse> {
-    const res = await getAgent().getAuthorFeed({
+    const res = await this.getAgent().getAuthorFeed({
       ...this.params,
       cursor,
       limit,