From 74d84cb2f22600b6246343e9ea606cf0db7517f0 Mon Sep 17 00:00:00 2001
From: polwex
Date: Wed, 19 Nov 2025 05:47:30 +0700
Subject: Big GUI improvements on Nostr rendering and fetching
---
gui/src/components/trill/Thread.tsx | 219 ++++++++++++++++++++++++++++++++++++
1 file changed, 219 insertions(+)
create mode 100644 gui/src/components/trill/Thread.tsx
(limited to 'gui/src/components/trill/Thread.tsx')
diff --git a/gui/src/components/trill/Thread.tsx b/gui/src/components/trill/Thread.tsx
new file mode 100644
index 0000000..a56ccf1
--- /dev/null
+++ b/gui/src/components/trill/Thread.tsx
@@ -0,0 +1,219 @@
+import useLocalState from "@/state/state";
+import Icon from "@/components/Icon";
+import spinner from "@/assets/triangles.svg";
+import Post from "@/components/post/Post";
+import { extractThread, toFlat } from "@/logic/trill/helpers";
+import type { FC, FullNode, Poast } from "@/types/trill";
+import Composer from "@/components/composer/Composer";
+import type { UserProfile } from "@/types/nostrill";
+import type { Ship } from "@/types/urbit";
+import { useEffect, useState } from "react";
+
+export default function Thread({
+ host,
+ id,
+ feed,
+ profile,
+}: {
+ host: Ship;
+ id: string;
+ feed?: FC;
+ profile?: UserProfile;
+}) {
+ const poast = feed?.feed[id];
+ console.log({ poast });
+ return (
+ <>
+
+
+
+
+
Thread
+
+ ~{host}
+ •
+ #{id}
+
+
+
+ {poast && poast.children.length === 0 ? (
+
+ ) : (
+
+ )}
+
+ >
+ );
+}
+function Loader({
+ host,
+ id,
+ profile,
+ poast,
+}: {
+ host: Ship;
+ id: string;
+ poast?: Poast;
+ profile?: UserProfile;
+}) {
+ const api = useLocalState((s) => s.api);
+ const [data, setData] = useState();
+ const [error, setError] = useState("");
+ console.log({ data });
+ async function fetchThread() {
+ const res = await api!.scryThread(host, id);
+ if ("error" in res) setError(res.error);
+ else setData(res.ok);
+ }
+ useEffect(() => {
+ fetchThread();
+ }, [host, id]);
+
+ if (data)
+ return (
+ <>
+
+
+
+
+ >
+ );
+ if (poast)
+ return (
+ <>
+
+
+
Loading Replies...
+
+

+
+
+ >
+ );
+ if (error)
+ return (
+
+
Error Loading Thread
+
{error}
+
+ );
+ else
+ return (
+
+
Loading Thread...
+
+

+
+
+ );
+}
+
+function Head({ poast, profile }: { poast: Poast; profile?: UserProfile }) {
+ return (
+
+ );
+}
+
+function ChildTree({ node }: { node: FullNode }) {
+ const profiles = useLocalState((s) => s.profiles);
+ const kids = Object.values(node.children || {});
+ kids.sort((a, b) => b.time - a.time);
+ return (
+ <>
+ {kids.map((k) => {
+ const profile = profiles.get(k.author);
+ return (
+
+ );
+ })}
+ >
+ );
+ function Grandchildren({ node }: { node: FullNode }) {
+ return (
+
+
+
+ );
+ }
+}
+// function ChildTree({ node }: { node: FullNode }) {
+// const { threadChildren, replies } = extractThread(node);
+// return (
+// <>
+//
+// {threadChildren.map((n) => {
+// return (
+//
+// );
+// })}
+//
+//
+// {replies.map((n) => (
+//
+// ))}
+//
+// >
+// );
+// }
+
+// function ReplyThread({ node }: { node: FullNode }) {
+// // const { threadChildren, replies } = extractThread(node);
+// const { replies } = extractThread(node);
+// return (
+//
+//
+//
+// {replies.map((r) => (
+//
+// ))}
+//
+//
+// );
+// }
+
+// function OwnData(props: Props) {
+// const { api } = useLocalState((s) => ({
+// api: s.api,
+// }));
+// const { host, id } = props;
+// async function fetchThread() {
+// return await api!.scryThread(host, id);
+// }
+// const { isLoading, isError, data, refetch } = useQuery({
+// queryKey: ["trill-thread", host, id],
+// queryFn: fetchThread,
+// });
+// return isLoading ? (
+//
+//
+//
Scrying Post, please wait...
+//

+//
+//
+// ) : null;
+// }
+// function SomeoneElses(props: Props) {
+// // const { api, following } = useLocalState((s) => ({
+// // api: s.api,
+// // following: s.following,
+// // }));
+// return ho
;
+// }
--
cgit v1.2.3