From 8751ba26ebf7b7761b9e237f2bf3453623dd1018 Mon Sep 17 00:00:00 2001
From: polwex <polwex@sortug.com>
Date: Mon, 6 Oct 2025 10:13:39 +0700
Subject: added frontend WS connection for demonstration purposes

---
 gui/src/components/post/Post.tsx | 85 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 gui/src/components/post/Post.tsx

(limited to 'gui/src/components/post/Post.tsx')

diff --git a/gui/src/components/post/Post.tsx b/gui/src/components/post/Post.tsx
new file mode 100644
index 0000000..2965040
--- /dev/null
+++ b/gui/src/components/post/Post.tsx
@@ -0,0 +1,85 @@
+import type { PostID, Poast, Reference } from "@/types/trill";
+
+import Header from "./Header";
+import Body from "./Body";
+import Footer from "./Footer";
+import { useLocation } from "wouter";
+import useLocalState from "@/state/state";
+import RP from "./RP";
+import ShipModal from "../modals/ShipModal";
+import type { Ship } from "@/types/urbit";
+import Sigil from "../Sigil";
+import type { UserProfile } from "@/types/nostrill";
+
+export interface PostProps {
+  poast: Poast;
+  fake?: boolean;
+  rter?: Ship;
+  rtat?: number;
+  rtid?: PostID;
+  nest?: number;
+  refetch?: Function;
+  profile?: UserProfile;
+}
+function Post(props: PostProps) {
+  console.log("post", props);
+  const { poast } = props;
+  if (!poast || poast.contents === null) {
+    return null;
+  }
+  const isRP =
+    poast.contents.length === 1 &&
+    "ref" in poast.contents[0] &&
+    poast.contents[0].ref.type === "trill";
+  if (isRP) {
+    const ref = (poast.contents[0] as Reference).ref;
+    return (
+      <RP
+        host={ref.ship}
+        id={ref.path.slice(1)}
+        rter={poast.author}
+        rtat={poast.time}
+        rtid={poast.id}
+      />
+    );
+  } else return <TrillPost {...props} />;
+}
+export default Post;
+
+function TrillPost(props: PostProps) {
+  const { poast, profile, fake } = props;
+  const setModal = useLocalState((s) => s.setModal);
+  const [_, navigate] = useLocation();
+  function openThread(_e: React.MouseEvent) {
+    const sel = window.getSelection()?.toString();
+    if (!sel) navigate(`/feed/${poast.host}/${poast.id}`);
+  }
+
+  function openModal(e: React.MouseEvent) {
+    e.stopPropagation();
+    setModal(<ShipModal ship={poast.author} />);
+  }
+  const avatar = profile ? (
+    <div className="avatar cp" role="link" onMouseUp={openModal}>
+      <img src={profile.picture} />
+    </div>
+  ) : (
+    <div className="avatar sigil cp" role="link" onMouseUp={openModal}>
+      <Sigil patp={poast.author} size={46} />
+    </div>
+  );
+  return (
+    <div
+      className={`timeline-post trill-post cp`}
+      role="link"
+      onMouseUp={openThread}
+    >
+      <div className="left">{avatar}</div>
+      <div className="right">
+        <Header {...props} />
+        <Body {...props} />
+        {!fake && <Footer {...props} />}
+      </div>
+    </div>
+  );
+}
-- 
cgit v1.2.3

