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/pages/Thread.tsx | 187 +++++++++-------------------------------------- 1 file changed, 36 insertions(+), 151 deletions(-) (limited to 'gui/src/pages/Thread.tsx') diff --git a/gui/src/pages/Thread.tsx b/gui/src/pages/Thread.tsx index fc215f2..a3d2234 100644 --- a/gui/src/pages/Thread.tsx +++ b/gui/src/pages/Thread.tsx @@ -1,167 +1,52 @@ import { useParams } from "wouter"; -import { useQuery } from "@tanstack/react-query"; import useLocalState from "@/state/state"; -import Icon from "@/components/Icon"; -import spinner from "@/assets/triangles.svg"; import { ErrorPage } from "@/pages/Error"; import "@/styles/trill.css"; import "@/styles/feed.css"; -import Post from "@/components/post/Post"; -import { extractThread, toFlat } from "@/logic/trill/helpers"; -import type { FullNode } from "@/types/trill"; -import Composer from "@/components/composer/Composer"; +import { stringToUser } from "@/logic/nostrill"; +import TrillThread from "@/components/trill/Thread"; +import NostrThread from "@/components/nostr/Thread"; +import { decodeNostrKey } from "@/logic/nostr"; + +export default function ThreadLoader() { + const { profiles, following } = useLocalState((s) => ({ + profiles: s.profiles, + following: s.following, + })); -export default function Thread() { const params = useParams<{ host: string; id: string }>(); const { host, id } = params; - const { api } = useLocalState((s) => ({ api: s.api })); - - async function fetchThread() { - return await api!.scryThread(host, id); - } - const { isPending, data, error } = useQuery({ - queryKey: ["thread", params.host, params.id], - queryFn: fetchThread, - enabled: !!api && !!params.host && !!params.id, - }); - - console.log({ data }); - if (!params.host || !params.id) { - return ; - } - if (isPending) { + const uuser = stringToUser(host); + if ("error" in uuser) return ; + const feed = following.get(host); + const profile = profiles.get(host); + if ("urbit" in uuser.ok) return ( -
-
-

Loading Thread...

-
-
- Loading -
-
+ ); - } - - if (error) { + if ("nostr" in uuser.ok) return ( -
-
-

Error Loading Thread

-
- -
+ ); - } - - if (!data || "error" in data) { - return ( -
-
-

Thread Not Found

-
- -
- ); - } - console.log({ data }); - // TODO make Composer a modal when in Thread mode - return ( -
-
-
- -
-

Thread

-
- ~{params.host} - - #{params.id} -
-
- -
- -
- -
-
- -
-
-
- ); + else return ; } -function ChildTree({ node }: { node: FullNode }) { - const { threadChildren, replies } = extractThread(node); - return ( - <> -
- {threadChildren.map((n) => { - return ; - })} -
-
- {replies.map((n) => ( - - ))} -
- - ); +export function NostrThreadLoader() { + const params = useParams<{ id: string }>(); + const { id } = params; + if (!id) return ; + const dec = decodeNostrKey(id); + if (!dec) return ; + return ; } - -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