johnandersen777.bsky.social/knotless
git that lives in your Atmosphere account
Forked from chadtmiller.com/knotless
0
0
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<typeof getViewer.main>(quiet, 'dev.knotless.getViewer', {}, true).catch(
() => null
);
const unread = viewer?.actor
? await xrpc<typeof getUnreadCount.main>(quiet, 'dev.knotless.getUnreadCount', {}, true).catch(
() => null
)
: null;
return { ...event.data, viewer, unread: unread?.count ?? 0 };
};