forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {type AppBskyFeedDefs, type BskyAgent} from '@atproto/api'
2
3import {type FeedAPI, type FeedAPIResponse} from './types'
4
5export class FollowingFeedAPI implements FeedAPI {
6 agent: BskyAgent
7
8 constructor({agent}: {agent: BskyAgent}) {
9 this.agent = agent
10 }
11
12 async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
13 const res = await this.agent.getTimeline({
14 limit: 1,
15 })
16 return res.data.feed[0]
17 }
18
19 async fetch({
20 cursor,
21 limit,
22 }: {
23 cursor: string | undefined
24 limit: number
25 }): Promise<FeedAPIResponse> {
26 const res = await this.agent.getTimeline({
27 cursor,
28 limit,
29 })
30 if (res.success) {
31 return {
32 cursor: res.data.cursor,
33 feed: res.data.feed,
34 }
35 }
36 return {
37 feed: [],
38 }
39 }
40}