* Update to react-query v5 * Introduce post-feed react query * Add feed refresh behaviors * Only fetch feeds of visible pages * Implement polling for latest on feeds * Add moderation filtering to slices * Handle block errors * Update feed error messages * Remove old models * Replace simple-feed option with disable-tuner option * Add missing useMemo * Implement the mergefeed and fixes to polling * Correctly handle failed load more state * Improve error and empty state behaviors * Clearer naming
44 lines
880 B
TypeScript
44 lines
880 B
TypeScript
import {
|
|
AppBskyFeedDefs,
|
|
AppBskyFeedGetActorLikes as GetActorLikes,
|
|
BskyAgent,
|
|
} from '@atproto/api'
|
|
import {FeedAPI, FeedAPIResponse} from './types'
|
|
|
|
export class LikesFeedAPI implements FeedAPI {
|
|
constructor(
|
|
public agent: BskyAgent,
|
|
public params: GetActorLikes.QueryParams,
|
|
) {}
|
|
|
|
async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
|
|
const res = await this.agent.getActorLikes({
|
|
...this.params,
|
|
limit: 1,
|
|
})
|
|
return res.data.feed[0]
|
|
}
|
|
|
|
async fetch({
|
|
cursor,
|
|
limit,
|
|
}: {
|
|
cursor: string | undefined
|
|
limit: number
|
|
}): Promise<FeedAPIResponse> {
|
|
const res = await this.agent.getActorLikes({
|
|
...this.params,
|
|
cursor,
|
|
limit,
|
|
})
|
|
if (res.success) {
|
|
return {
|
|
cursor: res.data.cursor,
|
|
feed: res.data.feed,
|
|
}
|
|
}
|
|
return {
|
|
feed: [],
|
|
}
|
|
}
|
|
}
|