import { jsonGet } from "$lib/api/_request"; import { getTrending } from "$lib/api/profile"; import { toRepoCard } from "$lib/components/timeline/mappers"; import type { BobbinContext } from "$lib/api/client"; import type * as ShTangledFeedGetTimeline from "$lib/api/lexicons/types/sh/tangled/feed/getTimeline"; const PAGE_LIMIT = 50; export interface LoadFeedOptions { ctx: BobbinContext; followingOnly: boolean; } // shared by /timeline and the signed-in homescreen at / export const loadFeed = async ({ ctx, followingOnly }: LoadFeedOptions) => { try { const { feed } = await jsonGet( ctx, "sh.tangled.feed.getTimeline", { followingOnly, limit: PAGE_LIMIT } ); return feed; } catch { return []; } }; export const loadTrendingRepos = async (ctx: BobbinContext) => { try { const trending = await getTrending(ctx); return trending.repos.map(toRepoCard); } catch { return []; } };