import type * as getUnreadCount from '#lib/lexicons/dev/knotless/getUnreadCount.ts'; import type * as getViewer from '#lib/lexicons/dev/knotless/getViewer.ts'; import type { LayoutLoad } from './$types'; import { xrpc } from '#lib/data.ts'; /** * Who is looking, as their session cookie says, and whether they can log * in here: none from a server that does not say, or fails to, as the page * is no less worth drawing; and how many of their notifications are new. * Each page is cached as its own answers are, not these. */ export const load: LayoutLoad = async (event) => { const quiet = { ...event, setHeaders: () => {} }; const viewer = await xrpc(quiet, 'dev.knotless.getViewer', {}, true).catch( () => null ); const unread = viewer?.actor ? await xrpc(quiet, 'dev.knotless.getUnreadCount', {}, true).catch( () => null ) : null; return { ...event.data, viewer, unread: unread?.count ?? 0 }; };