a tool for shared writing and social publishing
0

Configure Feed

Select the types of activity you want to include in your feed.

get cached bsky profile for user instead of through table

Jared Pereira (May 28, 2026, 3:49 PM EDT) 2ee289d3 8e89d6d0

+30 -6
+30 -6
actions/getIdentityData.ts
··· 4 4 import { supabaseServerClient } from "supabase/serverClient"; 5 5 import { cache } from "react"; 6 6 import { deduplicateByUri } from "src/utils/deduplicateRecords"; 7 + import { getProfiles, type Profile } from "src/identity"; 7 8 import { AtUri } from "@atproto/syntax"; 8 9 import { TID } from "@atproto/common"; 9 10 export const getIdentityData = cache(uncachedGetIdentityData); ··· 19 20 `*, 20 21 identities( 21 22 *, 22 - bsky_profiles(*), 23 23 notifications(count), 24 24 publication_subscriptions(*), 25 25 publication_email_subscribers(publication, state), ··· 74 74 75 75 const subscription = auth_res.data.identities.user_subscriptions ?? null; 76 76 77 - if (auth_res.data.identities.atp_did) { 77 + const atp_did = auth_res.data.identities.atp_did; 78 + if (atp_did) { 78 79 //I should create a relationship table so I can do this in the above query 79 - let { data: rawPublications } = await supabaseServerClient 80 - .from("publications") 81 - .select("*") 82 - .eq("identity_did", auth_res.data.identities.atp_did); 80 + let [{ data: rawPublications }, profiles] = await Promise.all([ 81 + supabaseServerClient 82 + .from("publications") 83 + .select("*") 84 + .eq("identity_did", atp_did), 85 + getProfiles([atp_did]), 86 + ]); 83 87 // Deduplicate records that may exist under both pub.leaflet and site.standard namespaces, 84 88 // then filter to only publications created by Leaflet 85 89 const publications = deduplicateByUri(rawPublications || []).filter( ··· 87 91 ); 88 92 return { 89 93 ...auth_res.data.identities, 94 + bsky_profiles: bskyProfileFromCache(profiles.get(atp_did) ?? null), 90 95 publications, 91 96 entitlements, 92 97 subscription, ··· 95 100 96 101 return { 97 102 ...auth_res.data.identities, 103 + bsky_profiles: null, 98 104 publications: [], 99 105 entitlements, 100 106 subscription, 107 + }; 108 + } 109 + 110 + // Reshape a cached profile into the legacy `bsky_profiles` row shape that 111 + // consumers (SubscribeButton, PubPreview, PostPreview, …) read off the 112 + // identity, so swapping the table join for the cache stays transparent. 113 + function bskyProfileFromCache(profile: Profile | null) { 114 + if (!profile) return null; 115 + return { 116 + did: profile.did, 117 + handle: profile.handle, 118 + record: { 119 + did: profile.did, 120 + handle: profile.handle, 121 + displayName: profile.displayName ?? undefined, 122 + avatar: profile.avatar ?? undefined, 123 + description: profile.description ?? undefined, 124 + }, 101 125 }; 102 126 } 103 127