From 7bac4927e8895719a91011da9a2b997579238145 Mon Sep 17 00:00:00 2001 From: polwex Date: Thu, 18 Sep 2025 08:26:30 +0700 Subject: damn my trill codebase was really something --- front/src/pages/Thread.tsx | 127 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 front/src/pages/Thread.tsx (limited to 'front/src/pages/Thread.tsx') diff --git a/front/src/pages/Thread.tsx b/front/src/pages/Thread.tsx new file mode 100644 index 0000000..8296f07 --- /dev/null +++ b/front/src/pages/Thread.tsx @@ -0,0 +1,127 @@ +import { useParams } from "wouter"; +import { useQuery } from "@tanstack/react-query"; +import useLocalState from "@/state/state"; +import PostList from "@/components/feed/PostList"; +import Composer from "@/components/composer/Composer"; +import Icon from "@/components/Icon"; +import spinner from "@/assets/triangles.svg"; +import { ErrorPage } from "@/Router"; +import "@/styles/trill.css"; +import "@/styles/feed.css"; +import Post from "@/components/post/Post"; +import { toFlat } from "@/logic/trill/helpers"; + +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, refetch } = 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) { + return ( +
+
+

Loading Thread...

+
+
+ Loading +
+
+ ); + } + + if (error) { + return ( +
+
+

Error Loading Thread

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

Thread Not Found

+
+ +
+ ); + } + + return ( +
+
+
+ +
+

Thread

+
+ ~{params.host} + + #{params.id} +
+
+ +
+ +
+ +
+
+
+ ); +} +// 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