tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
cache profile data
awarm.space
2 months ago
efbe8291
ae3813a4
+11
-8
1 changed file
expand all
collapse all
unified
split
app
(home-pages)
p
[didOrHandle]
layout.tsx
+11
-8
app/(home-pages)/p/[didOrHandle]/layout.tsx
···
9
9
import { Agent } from "@atproto/api";
10
10
import { get_profile_data } from "app/api/rpc/[command]/get_profile_data";
11
11
import { Metadata } from "next";
12
12
+
import { cache } from "react";
13
13
+
14
14
+
// Cache the profile data call to prevent concurrent OAuth restores
15
15
+
const getCachedProfileData = cache(async (did: string) => {
16
16
+
return get_profile_data.handler(
17
17
+
{ didOrHandle: did },
18
18
+
{ supabase: supabaseServerClient },
19
19
+
);
20
20
+
});
12
21
13
22
export async function generateMetadata(props: {
14
23
params: Promise<{ didOrHandle: string }>;
···
23
32
did = resolved;
24
33
}
25
34
26
26
-
let profileData = await get_profile_data.handler(
27
27
-
{ didOrHandle: did },
28
28
-
{ supabase: supabaseServerClient },
29
29
-
);
35
35
+
let profileData = await getCachedProfileData(did);
30
36
let { profile } = profileData.result;
31
37
32
38
if (!profile) return { title: "Profile - Leaflet" };
···
66
72
}
67
73
did = resolved;
68
74
}
69
69
-
let profileData = await get_profile_data.handler(
70
70
-
{ didOrHandle: did },
71
71
-
{ supabase: supabaseServerClient },
72
72
-
);
75
75
+
let profileData = await getCachedProfileData(did);
73
76
let { publications, profile } = profileData.result;
74
77
75
78
if (!profile) return null;