diff options
Diffstat (limited to 'src/lib/api/feed/author.ts')
-rw-r--r-- | src/lib/api/feed/author.ts | 21 |
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, |