Skip to content

Commit

Permalink
add hideRecord prop (#3527)
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius authored Apr 13, 2024
1 parent c1137c3 commit acbadc6
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions bskyembed/src/components/embed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import {Link} from './link'
export function Embed({
content,
labels,
hideRecord,
}: {
content: AppBskyFeedDefs.PostView['embed']
labels: AppBskyFeedDefs.PostView['labels']
hideRecord?: boolean
}) {
const labelInfo = useMemo(() => labelsToInfo(labels), [labels])

Expand All @@ -40,6 +42,10 @@ export function Embed({

// Case 3: Record (quote or linked post)
if (AppBskyEmbedRecord.isView(content)) {
if (hideRecord) {
return null
}

const record = content.record

// Case 3.1: Post
Expand Down Expand Up @@ -84,19 +90,14 @@ export function Embed({
</p>
</div>
{text && <p className="text-sm">{text}</p>}
{record.embeds
?.filter(embed => {
if (AppBskyEmbedImages.isView(embed)) return true
if (AppBskyEmbedExternal.isView(embed)) return true
return false
})
.map(embed => (
<Embed
key={embed.$type}
content={embed}
labels={record.labels}
/>
))}
{record.embeds?.map(embed => (
<Embed
key={embed.$type}
content={embed}
labels={record.labels}
hideRecord
/>
))}
</Link>
)
}
Expand Down Expand Up @@ -164,13 +165,18 @@ export function Embed({
) {
return (
<div className="flex flex-col gap-2">
<Embed content={content.media} labels={labels} />
<Embed
content={content.media}
labels={labels}
hideRecord={hideRecord}
/>
<Embed
content={{
$type: 'app.bsky.embed.record#view',
record: content.record.record,
}}
labels={content.record.record.labels}
hideRecord={hideRecord}
/>
</div>
)
Expand Down

0 comments on commit acbadc6

Please sign in to comment.