-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfeed.ts
More file actions
50 lines (45 loc) · 1.27 KB
/
feed.ts
File metadata and controls
50 lines (45 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import type {
AppBskyFeedGetFeed,
AppBskyFeedGetTimeline,
} from '@tsky/lexicons';
import type { Client } from '~/tsky/client';
import { Paginator } from '~/tsky/paginator';
export class Feed {
constructor(private client: Client) {}
/**
* Get a hydrated feed from an actor's selected feed generator. Implemented by App View.
*/
async getFeed(
params: AppBskyFeedGetFeed.Params,
options?: AppBskyFeedGetFeed.Input,
): Promise<Paginator<AppBskyFeedGetFeed.Output>> {
return Paginator.init(async (cursor) => {
const res = await this.client.get('app.bsky.feed.getFeed', {
...(options ?? {}),
params: {
cursor,
...params,
},
});
return res.data;
});
}
/**
* Get a view of the requesting account's home timeline. This is expected to be some form of reverse-chronological feed.
*/
getTimeline(
params: AppBskyFeedGetTimeline.Params,
options?: AppBskyFeedGetTimeline.Input,
): Promise<Paginator<AppBskyFeedGetTimeline.Output>> {
return Paginator.init(async (cursor) => {
const res = await this.client.get('app.bsky.feed.getTimeline', {
...(options ?? {}),
params: {
cursor,
...params,
},
});
return res.data;
});
}
}