From ec376960347a6255f1ec12c1758797ac30c073ff Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 25 Apr 2024 15:29:06 -0500 Subject: [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 --- src/lib/api/feed/author.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/lib/api/feed/author.ts') 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 { - 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 { - const res = await getAgent().getAuthorFeed({ + const res = await this.getAgent().getAuthorFeed({ ...this.params, cursor, limit, -- cgit 1.4.1