From 7bac4927e8895719a91011da9a2b997579238145 Mon Sep 17 00:00:00 2001
From: polwex <polwex@sortug.com>
Date: Thu, 18 Sep 2025 08:26:30 +0700
Subject: damn my trill codebase was really something

---
 front/src/components/composer/Snippets.tsx | 82 +++++++++++++++++++-----------
 1 file changed, 53 insertions(+), 29 deletions(-)

(limited to 'front/src/components/composer/Snippets.tsx')

diff --git a/front/src/components/composer/Snippets.tsx b/front/src/components/composer/Snippets.tsx
index 30498d0..49d9b88 100644
--- a/front/src/components/composer/Snippets.tsx
+++ b/front/src/components/composer/Snippets.tsx
@@ -1,5 +1,5 @@
 import Quote from "@/components/post/Quote";
-import type { ComposerData, SPID } from "@/types/ui";
+import type { SPID } from "@/types/ui";
 import { NostrSnippet } from "../post/wrappers/Nostr";
 
 export default Snippets;
@@ -20,43 +20,67 @@ export function ComposerSnippet({
 }) {
   function onc(e: React.MouseEvent) {
     e.stopPropagation();
-    onClick();
+    if (onClick) onClick();
   }
   return (
     <div className="composer-snippet">
-      <div className="pop-snippet-icon cp" role="link" onClick={onc}></div>
+      {onClick && (
+        <div className="pop-snippet-icon cp" role="link" onClick={onc}>
+          ×
+        </div>
+      )}
       {children}
     </div>
   );
 }
 function PostSnippet({ post }: { post: SPID }) {
-  if ("trill" in post) return <Quote data={post.trill} nest={0} />;
-  else if ("nostr" in post) return <NostrSnippet {...post.nostr} />;
-  // else if ("twatter" in post)
-  //   return (
-  //     <div id={`composer-${type}`}>
-  //       <Tweet tweet={post.post} quote={true} />
-  //     </div>
-  //   );
-  // else if ("rumors" in post)
-  //   return (
-  //     <div id={`composer-${type}`}>
-  //       <div className="rumor-quote f1">
-  //         <img src={rumorIcon} alt="" />
-  //         <Body poast={post.post} refetch={() => {}} />
-  //         <span>{date_diff(post.post.time, "short")}</span>
-  //       </div>
-  //     </div>
-  //   );
-  else return <></>;
+  if (!post) return <div className="snippet-error">No post data</div>;
+  
+  try {
+    if ("trill" in post) return <Quote data={post.trill} nest={0} />;
+    else if ("nostr" in post) return <NostrSnippet {...post.nostr} />;
+    // else if ("twatter" in post)
+    //   return (
+    //     <div id={`composer-${type}`}>
+    //       <Tweet tweet={post.post} quote={true} />
+    //     </div>
+    //   );
+    // else if ("rumors" in post)
+    //   return (
+    //     <div id={`composer-${type}`}>
+    //       <div className="rumor-quote f1">
+    //         <img src={rumorIcon} alt="" />
+    //         <Body poast={post.post} refetch={() => {}} />
+    //         <span>{date_diff(post.post.time, "short")}</span>
+    //       </div>
+    //     </div>
+    //   );
+    else return <div className="snippet-error">Unsupported post type</div>;
+  } catch (error) {
+    console.error("Error rendering post snippet:", error);
+    return <div className="snippet-error">Failed to load post</div>;
+  }
 }
 
 export function ReplySnippet({ post }: { post: SPID }) {
-  if ("trill" in post)
-    return (
-      <div id="reply">
-        <Quote data={post.trill} nest={0} />
-      </div>
-    );
-  else return <div />;
+  if (!post) return <div className="snippet-error">No post to reply to</div>;
+  
+  try {
+    if ("trill" in post)
+      return (
+        <div id="reply" className="reply-snippet">
+          <Quote data={post.trill} nest={0} />
+        </div>
+      );
+    else if ("nostr" in post)
+      return (
+        <div id="reply" className="reply-snippet">
+          <NostrSnippet {...post.nostr} />
+        </div>
+      );
+    else return <div className="snippet-error">Cannot reply to this post type</div>;
+  } catch (error) {
+    console.error("Error rendering reply snippet:", error);
+    return <div className="snippet-error">Failed to load reply context</div>;
+  }
 }
-- 
cgit v1.2.3

