frontend for xcvr appview
1import type { LayoutLoad } from "./$types"
2
3export const load: LayoutLoad = async ({ fetch }) => {
4 const results = await Promise.allSettled([
5 fetch(`${import.meta.env.VITE_API_URL}/xrpc/org.xcvr.feed.getChannels`)
6 .then(r => r.ok ? r.json() : []),
7 fetch(`${import.meta.env.VITE_API_URL}/oauth/whoami`)
8 .then(r => r.ok ? r.json() : null)
9 ])
10 return {
11 channels: results[0].status === 'fulfilled' ? results[0].value : [],
12 myProfile: results[1].status === 'fulfilled' && results[1].value !== null ? { ...(results[1].value), loggedIn: true } : {
13 handle: "xcvr.org",
14 defaultNick: "wanderer",
15 color: Math.floor(Math.random() * 16777216),
16 loggedIn: false,
17 }
18 }
19}