Monorepo for Tangled tangled.org
1

Configure Feed

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

core / web / src / routes / timeline / +page.ts
1.1 kB 28 lines
1import { createBobbinClient } from "$lib/api/client"; 2import { jsonGet } from "$lib/api/_request"; 3import { toHttpError } from "$lib/api/load"; 4import type * as ShTangledFeedGetTimeline from "$lib/api/lexicons/types/sh/tangled/feed/getTimeline"; 5import type { PageLoad } from "./$types"; 6 7const PAGE_LIMIT = 50; 8 9export const load: PageLoad = async (event) => { 10 const parent = await event.parent(); 11 const ctx = createBobbinClient({ serviceUrl: parent.publicConfig.bobbinUrl, fetch: event.fetch }); 12 const viewer = parent.auth?.did; 13 14 // the following feed needs a viewer to resolve the followed set; bobbin 400s without one 15 const followingOnly = event.url.searchParams.get("following") === "true" && viewer !== undefined; 16 17 try { 18 // output key is `feed`, not `items`, so the pagination.ts helpers don't apply 19 const { feed } = await jsonGet<ShTangledFeedGetTimeline.$output>( 20 ctx, 21 "sh.tangled.feed.getTimeline", 22 { viewer, followingOnly, limit: PAGE_LIMIT } 23 ); 24 return { feed, followingOnly, signedIn: viewer !== undefined }; 25 } catch (cause) { 26 toHttpError(cause, "Could not load timeline"); 27 } 28};