tangled
alpha
login
or
join now
isuggest.selfce.st
/
strand
3
fork
atom
alternative tangled frontend (extremely wip)
3
fork
atom
overview
issues
pulls
pipelines
refactor: move profile queries to loader
serenity
2 weeks ago
3f1aa9f0
7c5255a1
+24
1 changed file
expand all
collapse all
unified
split
src
routes
_layout
$identifier
index.tsx
+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
7
+
import { miniDocQueryOptions } from "@/lib/queries/resolve-minidoc";
8
8
+
import { avatarQueryOptions } from "@/lib/queries/get-avatar";
9
9
+
import {
10
10
+
profileQueryKey,
11
11
+
profileQueryOptions,
12
12
+
} from "@/lib/queries/get-profile";
13
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
20
+
loader: async ({ params, context: { queryClient } }) => {
21
21
+
const miniDoc = await queryClient.ensureQueryData(
22
22
+
miniDocQueryOptions(params.identifier),
23
23
+
);
24
24
+
25
25
+
const shared = { did: miniDoc.did, repoUrl: new URL(miniDoc.pds) };
26
26
+
27
27
+
await Promise.all([
28
28
+
queryClient.ensureQueryData(avatarQueryOptions(shared)),
29
29
+
queryClient.ensureQueryData(profileQueryOptions(shared)),
30
30
+
queryClient.prefetchQuery(
31
31
+
reposQueryOptions({ ...shared, cursor: null }),
32
32
+
),
33
33
+
]);
34
34
+
35
35
+
return { did: miniDoc.did, repoUrl: miniDoc.pds };
36
36
+
},
13
37
component: RouteComponent,
14
38
validateSearch: paramsSchema,
15
39
});