Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Add accept-language header (#2457)

authored by

Cooper Edmunds and committed by
GitHub
7df0b7ad 1d3e2022

+28 -14
+18 -9
src/lib/api/feed/custom.ts
··· 4 4 } from '@atproto/api' 5 5 import {FeedAPI, FeedAPIResponse} from './types' 6 6 import {getAgent} from '#/state/session' 7 + import {getContentLanguages} from '#/state/preferences/languages' 7 8 8 9 export class CustomFeedAPI implements FeedAPI { 9 10 constructor(public params: GetCustomFeed.QueryParams) {} 10 11 11 12 async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> { 12 - const res = await getAgent().app.bsky.feed.getFeed({ 13 - ...this.params, 14 - limit: 1, 15 - }) 13 + const contentLangs = getContentLanguages().join(',') 14 + const res = await getAgent().app.bsky.feed.getFeed( 15 + { 16 + ...this.params, 17 + limit: 1, 18 + }, 19 + {headers: {'Accept-Language': contentLangs}}, 20 + ) 16 21 return res.data.feed[0] 17 22 } 18 23 ··· 23 28 cursor: string | undefined 24 29 limit: number 25 30 }): Promise<FeedAPIResponse> { 26 - const res = await getAgent().app.bsky.feed.getFeed({ 27 - ...this.params, 28 - cursor, 29 - limit, 30 - }) 31 + const contentLangs = getContentLanguages().join(',') 32 + const res = await getAgent().app.bsky.feed.getFeed( 33 + { 34 + ...this.params, 35 + cursor, 36 + limit, 37 + }, 38 + {headers: {'Accept-Language': contentLangs}}, 39 + ) 31 40 if (res.success) { 32 41 // NOTE 33 42 // some custom feeds fail to enforce the pagination limit
+10 -5
src/lib/api/feed/merge.ts
··· 8 8 import {FeedParams} from '#/state/queries/post-feed' 9 9 import {FeedTunerFn} from '../feed-manip' 10 10 import {getAgent} from '#/state/session' 11 + import {getContentLanguages} from '#/state/preferences/languages' 11 12 12 13 const REQUEST_WAIT_MS = 500 // 500ms 13 14 const POST_AGE_CUTOFF = 60e3 * 60 * 24 // 24hours ··· 231 232 limit: number, 232 233 ): Promise<AppBskyFeedGetTimeline.Response> { 233 234 try { 234 - const res = await getAgent().app.bsky.feed.getFeed({ 235 - cursor, 236 - limit, 237 - feed: this.feedUri, 238 - }) 235 + const contentLangs = getContentLanguages().join(',') 236 + const res = await getAgent().app.bsky.feed.getFeed( 237 + { 238 + cursor, 239 + limit, 240 + feed: this.feedUri, 241 + }, 242 + {headers: {'Accept-Language': contentLangs}}, 243 + ) 239 244 // NOTE 240 245 // some custom feeds fail to enforce the pagination limit 241 246 // so we manually truncate here