Skip to content

Commit c916a66

Browse files
committed
Fix missing embeds in fallback posts and thread fallback
- Add resolveRecordEmbeds() to convert raw blob refs into CDN URLs for external link cards, images, videos, and recordWithMedia embeds - Wire resolved embeds into buildSyntheticPostView and buildSyntheticEmbedViewRecord so fallback posts render media - Fix thread fallback: intercept threadItemNotFound from AppView and load post via Slingshot instead of showing "Post not found" - Add moderation checks to thread fallback to prevent bypassing takedowns/suspensions - Add quoteCount from Constellation backlink data - Use record createdAt as indexedAt to prevent false archived post warning - Change "Bluesky" to "Blacksky" in archived post dialog
1 parent fb65bd1 commit c916a66

6 files changed

Lines changed: 438 additions & 34 deletions

File tree

src/components/Post/Embed/index.tsx

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {useQueryClient} from '@tanstack/react-query'
1313

1414
import {makeProfileLink} from '#/lib/routes/links'
1515
import {useModerationOpts} from '#/state/preferences/moderation-opts'
16+
import {useEmbedFallback} from '#/state/queries/embed-fallback'
1617
import {unstableCacheProfileView} from '#/state/queries/profile'
1718
import {useSession} from '#/state/session'
1819
import {Link} from '#/view/com/util/Link'
@@ -174,11 +175,7 @@ function RecordEmbed({
174175
)
175176
}
176177
case 'post_not_found': {
177-
return (
178-
<PostPlaceholderText>
179-
<Trans>Deleted</Trans>
180-
</PostPlaceholderText>
181-
)
178+
return <PostNotFoundEmbed embed={embed} {...rest} />
182179
}
183180
case 'post_blocked': {
184181
return (
@@ -217,6 +214,49 @@ export function PostDetachedEmbed({
217214
)
218215
}
219216

217+
/*
218+
* Attempts Slingshot fallback before showing "Deleted" for embedded posts
219+
* that our appview hasn't synced yet.
220+
*/
221+
function PostNotFoundEmbed({
222+
embed,
223+
...rest
224+
}: CommonProps & {embed: EmbedType<'post_not_found'>}) {
225+
const {data: fallbackRecord, isLoading} = useEmbedFallback({
226+
uri: embed.view.uri,
227+
})
228+
229+
if (isLoading) {
230+
return (
231+
<PostPlaceholderText>
232+
<Trans>Loading...</Trans>
233+
</PostPlaceholderText>
234+
)
235+
}
236+
237+
if (fallbackRecord) {
238+
return (
239+
<QuoteEmbed
240+
{...rest}
241+
embed={{type: 'post', view: fallbackRecord}}
242+
viewContext={
243+
rest.viewContext === PostEmbedViewContext.Feed
244+
? QuoteEmbedViewContext.FeedEmbedRecordWithMedia
245+
: undefined
246+
}
247+
isWithinQuote={rest.isWithinQuote}
248+
allowNestedQuotes={rest.allowNestedQuotes}
249+
/>
250+
)
251+
}
252+
253+
return (
254+
<PostPlaceholderText>
255+
<Trans>Deleted</Trans>
256+
</PostPlaceholderText>
257+
)
258+
}
259+
220260
/*
221261
* Nests parent `Embed` component and therefore must live in this file to avoid
222262
* circular imports.

src/screens/PostThread/components/ThreadItemAnchor.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ function ExpandedPostDetails({
553553
() =>
554554
Boolean(
555555
langPrefs.primaryLanguage &&
556-
!isPostInLanguage(post, [langPrefs.primaryLanguage]),
556+
!isPostInLanguage(post, [langPrefs.primaryLanguage]),
557557
),
558558
[post, langPrefs.primaryLanguage],
559559
)
@@ -688,7 +688,7 @@ function BackdatedPostIndicator({post}: {post: AppBskyFeedDefs.PostView}) {
688688
<RNText style={[a.font_semi_bold]}>
689689
{niceDate(i18n, createdAt)}
690690
</RNText>
691-
, but was first seen by Bluesky on{' '}
691+
, but was first seen by Blacksky on{' '}
692692
<RNText style={[a.font_semi_bold]}>
693693
{niceDate(i18n, indexedAt)}
694694
</RNText>
@@ -697,7 +697,7 @@ function BackdatedPostIndicator({post}: {post: AppBskyFeedDefs.PostView}) {
697697
</Prompt.DescriptionText>
698698
<Prompt.DescriptionText>
699699
<Trans>
700-
Bluesky cannot confirm the authenticity of the claimed date.
700+
Blacksky cannot confirm the authenticity of the claimed date.
701701
</Trans>
702702
</Prompt.DescriptionText>
703703
</Prompt.Content>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import {useQuery, useQueryClient} from '@tanstack/react-query'
2+
3+
import {STALE} from '#/state/queries'
4+
import {buildSyntheticEmbedViewRecord} from './microcosm-fallback'
5+
6+
const RQKEY_ROOT = 'embed-fallback'
7+
export const RQKEY = (uri: string) => [RQKEY_ROOT, uri]
8+
9+
export function useEmbedFallback({uri}: {uri: string}) {
10+
const queryClient = useQueryClient()
11+
12+
return useQuery({
13+
staleTime: STALE.HOURS.ONE,
14+
queryKey: RQKEY(uri),
15+
async queryFn() {
16+
const result = await buildSyntheticEmbedViewRecord(queryClient, uri)
17+
return result ?? undefined
18+
},
19+
enabled: !!uri,
20+
})
21+
}

0 commit comments

Comments
 (0)