Bluesky app fork with some witchin' additions 馃挮 witchsky.app
bluesky fork client
120
fork

Configure Feed

Select the types of activity you want to include in your feed.

at d42a2808ba53a049fc38f559feeddaa5a335f93f 52 lines 1.2 kB view raw
1import { 2 type Agent, 3 type AppBskyFeedDefs, 4 type AppBskyFeedGetPosts, 5} from '@atproto/api' 6 7import {logger} from '#/logger' 8import {type FeedAPI, type FeedAPIResponse} from './types' 9 10export class PostListFeedAPI implements FeedAPI { 11 agent: Agent 12 params: AppBskyFeedGetPosts.QueryParams 13 peek: AppBskyFeedDefs.FeedViewPost | null = null 14 15 constructor({ 16 agent, 17 feedParams, 18 }: { 19 agent: Agent 20 feedParams: AppBskyFeedGetPosts.QueryParams 21 }) { 22 this.agent = agent 23 if (feedParams.uris.length > 25) { 24 logger.warn( 25 `Too many URIs provided - expected 25, got ${feedParams.uris.length}`, 26 ) 27 } 28 this.params = { 29 uris: feedParams.uris.slice(0, 25), 30 } 31 } 32 33 async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> { 34 if (this.peek) return this.peek 35 throw new Error('Has not fetched yet') 36 } 37 38 async fetch({}: {}): Promise<FeedAPIResponse> { 39 const res = await this.agent.app.bsky.feed.getPosts({ 40 ...this.params, 41 }) 42 if (res.success) { 43 this.peek = {post: res.data.posts[0]} 44 return { 45 feed: res.data.posts.map(post => ({post})), 46 } 47 } 48 return { 49 feed: [], 50 } 51 } 52}