From acbadc610bc373752cf19e17ea48d1921dd5315e Mon Sep 17 00:00:00 2001
From: Samuel Newman <mozzius@protonmail.com>
Date: Sat, 13 Apr 2024 11:42:23 +0100
Subject: add hideRecord prop (#3527)

---
 bskyembed/src/components/embed.tsx | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

(limited to 'bskyembed/src/components/embed.tsx')

diff --git a/bskyembed/src/components/embed.tsx b/bskyembed/src/components/embed.tsx
index d88019965..4457defce 100644
--- a/bskyembed/src/components/embed.tsx
+++ b/bskyembed/src/components/embed.tsx
@@ -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])
 
@@ -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
@@ -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>
         )
       }
@@ -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>
       )
-- 
cgit 1.4.1

