add hideRecord prop (#3527)
parent
c1137c3984
commit
acbadc610b
|
@ -19,9 +19,11 @@ import {Link} from './link'
|
||||||
export function Embed({
|
export function Embed({
|
||||||
content,
|
content,
|
||||||
labels,
|
labels,
|
||||||
|
hideRecord,
|
||||||
}: {
|
}: {
|
||||||
content: AppBskyFeedDefs.PostView['embed']
|
content: AppBskyFeedDefs.PostView['embed']
|
||||||
labels: AppBskyFeedDefs.PostView['labels']
|
labels: AppBskyFeedDefs.PostView['labels']
|
||||||
|
hideRecord?: boolean
|
||||||
}) {
|
}) {
|
||||||
const labelInfo = useMemo(() => labelsToInfo(labels), [labels])
|
const labelInfo = useMemo(() => labelsToInfo(labels), [labels])
|
||||||
|
|
||||||
|
@ -40,6 +42,10 @@ export function Embed({
|
||||||
|
|
||||||
// Case 3: Record (quote or linked post)
|
// Case 3: Record (quote or linked post)
|
||||||
if (AppBskyEmbedRecord.isView(content)) {
|
if (AppBskyEmbedRecord.isView(content)) {
|
||||||
|
if (hideRecord) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
const record = content.record
|
const record = content.record
|
||||||
|
|
||||||
// Case 3.1: Post
|
// Case 3.1: Post
|
||||||
|
@ -84,17 +90,12 @@ export function Embed({
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{text && <p className="text-sm">{text}</p>}
|
{text && <p className="text-sm">{text}</p>}
|
||||||
{record.embeds
|
{record.embeds?.map(embed => (
|
||||||
?.filter(embed => {
|
|
||||||
if (AppBskyEmbedImages.isView(embed)) return true
|
|
||||||
if (AppBskyEmbedExternal.isView(embed)) return true
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
.map(embed => (
|
|
||||||
<Embed
|
<Embed
|
||||||
key={embed.$type}
|
key={embed.$type}
|
||||||
content={embed}
|
content={embed}
|
||||||
labels={record.labels}
|
labels={record.labels}
|
||||||
|
hideRecord
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -164,13 +165,18 @@ export function Embed({
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<Embed content={content.media} labels={labels} />
|
<Embed
|
||||||
|
content={content.media}
|
||||||
|
labels={labels}
|
||||||
|
hideRecord={hideRecord}
|
||||||
|
/>
|
||||||
<Embed
|
<Embed
|
||||||
content={{
|
content={{
|
||||||
$type: 'app.bsky.embed.record#view',
|
$type: 'app.bsky.embed.record#view',
|
||||||
record: content.record.record,
|
record: content.record.record,
|
||||||
}}
|
}}
|
||||||
labels={content.record.record.labels}
|
labels={content.record.record.labels}
|
||||||
|
hideRecord={hideRecord}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue