view who was fronting when a record was made

feat: show fronter for grandparent author

ptr.pet 8f4ed1bd b162e62e

verified
+22 -15
+22 -15
src/entrypoints/background.ts
··· 1 - import { PersistentCache } from "@/lib/cache"; 2 1 import { expect } from "@/lib/result"; 3 2 import { 4 3 type Fronter, ··· 11 10 displayNameCache, 12 11 deleteFronter, 13 12 getPkFronters, 14 - FronterType, 15 13 FronterView, 16 14 } from "@/lib/utils"; 17 - import { 18 - ComAtprotoRepoApplyWrites, 19 - ComAtprotoRepoCreateRecord, 20 - } from "@atcute/atproto"; 21 - import { createResultSchema } from "@atcute/atproto/types/repo/applyWrites"; 15 + import { AppBskyFeedPost } from "@atcute/bluesky"; 22 16 import { feedViewPostSchema } from "@atcute/bluesky/types/app/feed/defs"; 23 - import { 24 - InferOutput, 25 - is, 26 - parseResourceUri, 27 - ResourceUri, 28 - safeParse, 29 - } from "@atcute/lexicons"; 17 + import { is, parseResourceUri, ResourceUri } from "@atcute/lexicons"; 30 18 import { AtprotoDid, parseCanonicalResourceUri } from "@atcute/lexicons/syntax"; 31 19 32 20 export default defineBackground({ ··· 172 160 }, 173 161 ...fronter, 174 162 }; 175 - } else if (uri === item.post.uri) { 163 + } else if ( 164 + uri === item.post.uri && 165 + item.reply?.parent.$type === "app.bsky.feed.defs#postView" 166 + ) { 176 167 fronter = { 177 168 replyTo: item.reply?.parent.uri, 178 169 ...fronter, 179 170 }; 171 + } else if ( 172 + uri === item.reply?.parent.uri && 173 + item.reply?.parent.$type === "app.bsky.feed.defs#postView" 174 + ) { 175 + fronter = { 176 + replyTo: (item.reply.parent.record as AppBskyFeedPost.Main) 177 + .reply?.parent.uri, 178 + ...fronter, 179 + }; 180 180 } 181 181 const parsedUri = await cacheFronter(uri, fronter); 182 182 return { ··· 191 191 promises.push(handleUri(item.post.uri, "post")); 192 192 if (item.reply?.parent) { 193 193 promises.push(handleUri(item.reply.parent.uri, "post")); 194 + if (item.reply?.parent.$type === "app.bsky.feed.defs#postView") { 195 + const grandparentUri = ( 196 + item.reply.parent.record as AppBskyFeedPost.Main 197 + ).reply?.parent.uri; 198 + if (grandparentUri) 199 + promises.push(handleUri(grandparentUri, "post")); 200 + } 194 201 } 195 202 if (item.reply?.root) { 196 203 promises.push(handleUri(item.reply.root.uri, "post"));