alternative tangled frontend (extremely wip)

refactor: move profile queries to loader

serenity 3f1aa9f0 7c5255a1

+24
+24
src/routes/_layout/$identifier/index.tsx
··· 4 4 import { UnderlineIconRouterLink } from "@/components/Animated/UnderlineIconRouterLink"; 5 5 import { z } from "zod/v4"; 6 6 import { ProfileOverview } from "@/components/Profile/ProfileOverview"; 7 + import { miniDocQueryOptions } from "@/lib/queries/resolve-minidoc"; 8 + import { avatarQueryOptions } from "@/lib/queries/get-avatar"; 9 + import { 10 + profileQueryKey, 11 + profileQueryOptions, 12 + } from "@/lib/queries/get-profile"; 13 + import { reposQueryOptions } from "@/lib/queries/get-repos"; 7 14 8 15 const paramsSchema = z.object({ 9 16 tab: z.string().optional(), 10 17 }); 11 18 12 19 export const Route = createFileRoute("/_layout/$identifier/")({ 20 + loader: async ({ params, context: { queryClient } }) => { 21 + const miniDoc = await queryClient.ensureQueryData( 22 + miniDocQueryOptions(params.identifier), 23 + ); 24 + 25 + const shared = { did: miniDoc.did, repoUrl: new URL(miniDoc.pds) }; 26 + 27 + await Promise.all([ 28 + queryClient.ensureQueryData(avatarQueryOptions(shared)), 29 + queryClient.ensureQueryData(profileQueryOptions(shared)), 30 + queryClient.prefetchQuery( 31 + reposQueryOptions({ ...shared, cursor: null }), 32 + ), 33 + ]); 34 + 35 + return { did: miniDoc.did, repoUrl: miniDoc.pds }; 36 + }, 13 37 component: RouteComponent, 14 38 validateSearch: paramsSchema, 15 39 });