diff options
Diffstat (limited to 'src/lib/api/feed/list.ts')
-rw-r--r-- | src/lib/api/feed/list.ts | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/lib/api/feed/list.ts b/src/lib/api/feed/list.ts index 19f2ff177..004685b99 100644 --- a/src/lib/api/feed/list.ts +++ b/src/lib/api/feed/list.ts @@ -1,15 +1,28 @@ import { AppBskyFeedDefs, AppBskyFeedGetListFeed as GetListFeed, + BskyAgent, } from '@atproto/api' + import {FeedAPI, FeedAPIResponse} from './types' -import {getAgent} from '#/state/session' export class ListFeedAPI implements FeedAPI { - constructor(public params: GetListFeed.QueryParams) {} + getAgent: () => BskyAgent + params: GetListFeed.QueryParams + + constructor({ + getAgent, + feedParams, + }: { + getAgent: () => BskyAgent + feedParams: GetListFeed.QueryParams + }) { + this.getAgent = getAgent + this.params = feedParams + } async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> { - const res = await getAgent().app.bsky.feed.getListFeed({ + const res = await this.getAgent().app.bsky.feed.getListFeed({ ...this.params, limit: 1, }) @@ -23,7 +36,7 @@ export class ListFeedAPI implements FeedAPI { cursor: string | undefined limit: number }): Promise<FeedAPIResponse> { - const res = await getAgent().app.bsky.feed.getListFeed({ + const res = await this.getAgent().app.bsky.feed.getListFeed({ ...this.params, cursor, limit, |