Skip to content

Commit edcac2d

Browse files
committed
✨ Add fallback for takendown accounts too
1 parent 0c9c904 commit edcac2d

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

app/actions/ModActionPanel/QuickAction.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,10 @@ function Form(
596596
<div className="max-w-xl">
597597
<PreviewCard
598598
subject={subject}
599-
isAuthorDeactivated={!!record?.repo?.deactivatedAt}
599+
isAuthorDeactivated={!!record?.repo.deactivatedAt}
600+
isAuthorTakendown={
601+
!!record?.repo.moderation.subjectStatus?.takendown
602+
}
600603
className="border-2 border-dashed border-gray-300"
601604
>
602605
{!isSubjectDid && record?.repo && (

components/common/PreviewCard.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ export function PreviewCard({
2929
children,
3030
className,
3131
isAuthorDeactivated,
32+
isAuthorTakendown,
3233
}: {
3334
subject: string
3435
isAuthorDeactivated?: boolean
36+
isAuthorTakendown?: boolean
3537
title?: string | ReactNode
3638
children?: ReactNode
3739
className?: string
@@ -43,7 +45,11 @@ export function PreviewCard({
4345
<p className="text-sm font-medium text-gray-500 dark:text-gray-50 mb-3">
4446
{displayTitle}
4547
</p>
46-
<RecordCard uri={subject} isAuthorDeactivated={isAuthorDeactivated} />
48+
<RecordCard
49+
uri={subject}
50+
isAuthorDeactivated={isAuthorDeactivated}
51+
isAuthorTakendown={isAuthorTakendown}
52+
/>
4753
{children}
4854
</div>
4955
)

components/common/RecordCard.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ export function RecordCard(props: {
2121
uri: string
2222
showLabels?: boolean
2323
isAuthorDeactivated?: boolean
24+
isAuthorTakendown?: boolean
2425
}) {
25-
const { uri, showLabels = false, isAuthorDeactivated } = props
26+
const {
27+
uri,
28+
showLabels = false,
29+
isAuthorDeactivated,
30+
isAuthorTakendown,
31+
} = props
2632
const parsed = parseAtUri(uri)
2733
if (!parsed) {
2834
return null
@@ -32,6 +38,7 @@ export function RecordCard(props: {
3238
<PostCard
3339
uri={uri}
3440
showLabels={showLabels}
41+
isAuthorTakendown={isAuthorTakendown}
3542
isAuthorDeactivated={isAuthorDeactivated}
3643
/>
3744
)
@@ -66,10 +73,12 @@ export function RecordCard(props: {
6673
function PostCard({
6774
uri,
6875
showLabels,
76+
isAuthorTakendown,
6977
isAuthorDeactivated,
7078
}: {
7179
uri: string
7280
showLabels?: boolean
81+
isAuthorTakendown?: boolean
7382
isAuthorDeactivated?: boolean
7483
}) {
7584
const labelerAgent = useLabelerAgent()
@@ -136,6 +145,7 @@ function PostCard({
136145
dense
137146
showLabels={showLabels}
138147
item={{ post: data.thread.post }}
148+
isAuthorTakendown={isAuthorTakendown}
139149
isAuthorDeactivated={isAuthorDeactivated}
140150
controls={['like', 'repost', 'workspace']}
141151
/>

components/common/posts/PostsFeed.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,13 @@ export function PostAsCard({
8989
className = '',
9090
showLabels = true,
9191
isAuthorDeactivated,
92+
isAuthorTakendown,
9293
controls = [...PostControlOptions],
9394
}: {
9495
item: AppBskyFeedDefs.FeedViewPost
9596
dense?: boolean
9697
isAuthorDeactivated?: boolean
98+
isAuthorTakendown?: boolean
9799
controls?: PostControl[]
98100
onReport?: (uri: string) => void
99101
className?: string
@@ -103,7 +105,11 @@ export function PostAsCard({
103105
<div className={`bg-white dark:bg-slate-800 ${className}`}>
104106
<PostHeader item={item} dense={dense} />
105107
<PostContent item={item} dense={dense} />
106-
<PostEmbeds item={item} isAuthorDeactivated={isAuthorDeactivated} />
108+
<PostEmbeds
109+
item={item}
110+
isAuthorTakendown={isAuthorTakendown}
111+
isAuthorDeactivated={isAuthorDeactivated}
112+
/>
107113
{showLabels && <PostLabels item={item} dense={dense} />}
108114
{!!controls?.length && (
109115
<PostControls item={item} onReport={onReport} controls={controls} />
@@ -242,8 +248,10 @@ const getImageSizeClass = (imageCount: number) =>
242248

243249
export function PostEmbeds({
244250
item,
251+
isAuthorTakendown,
245252
isAuthorDeactivated,
246253
}: {
254+
isAuthorTakendown?: boolean
247255
isAuthorDeactivated?: boolean
248256
item: AppBskyFeedDefs.FeedViewPost
249257
}) {
@@ -265,10 +273,12 @@ export function PostEmbeds({
265273
const captions = item.post.record?.['embed']?.['captions']
266274
const sourceUrl = getVideoUrlWithFallback(embed.playlist, {
267275
isAuthorDeactivated,
276+
isAuthorTakendown,
268277
})
269278
const thumbnailUrl = embed.thumbnail
270279
? getVideoUrlWithFallback(embed.thumbnail, {
271280
isAuthorDeactivated,
281+
isAuthorTakendown,
272282
})
273283
: undefined
274284
return (

components/common/video/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { FALLBACK_VIDEO_URL } from '@/lib/constants'
22

33
export const getVideoUrlWithFallback = (
44
originalUri: string,
5-
opts?: { isAuthorDeactivated?: boolean },
5+
opts?: { isAuthorDeactivated?: boolean; isAuthorTakendown?: boolean },
66
): string => {
77
const [find, replace] = FALLBACK_VIDEO_URL
88
if (!find || !replace) {
99
return originalUri
1010
}
1111

12-
if (!opts?.isAuthorDeactivated) {
12+
if (!opts?.isAuthorDeactivated && !opts?.isAuthorTakendown) {
1313
return originalUri
1414
}
1515

0 commit comments

Comments
 (0)