feat: paginate tweet conversations

This commit is contained in:
2026-07-14 00:29:03 +09:00
parent 1eb2733b38
commit 8e6ff70d81
5 changed files with 204 additions and 39 deletions
+15 -1
View File
@@ -1,4 +1,4 @@
import type { Post, PostPage } from './types'
import type { Post, PostPage, ThreadPage } from './types'
export function flattenPostPages(pages: PostPage[]): Post[] {
const seen = new Set<string>()
@@ -10,3 +10,17 @@ export function flattenPostPages(pages: PostPage[]): Post[] {
}),
)
}
export function focalPostFromPages(
pages: Array<PostPage | ThreadPage>,
): Post | undefined {
const first = pages[0]
return first && 'focalPost' in first ? first.focalPost : undefined
}
export function flattenConversationPages(
pages: Array<PostPage | ThreadPage>,
focalPostId: string,
): Post[] {
return flattenPostPages(pages).filter(({ id }) => id !== focalPostId)
}