Files
twitter-lite/src/features/posts/page.ts
T

13 lines
307 B
TypeScript

import type { Post, PostPage } from "./types";
export function flattenPostPages(pages: PostPage[]): Post[] {
const seen = new Set<string>();
return pages.flatMap(({ tweets }) =>
tweets.filter(({ id }) => {
if (seen.has(id)) return false;
seen.add(id);
return true;
}),
);
}