From b1d68ac307ed87d63e83820cbdf843fff0fd9f7f Mon Sep 17 00:00:00 2001
From: polwex <polwex@sortug.com>
Date: Thu, 11 Sep 2025 01:48:14 +0700
Subject: init

---
 front/src/pages/Feed.tsx | 104 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
 create mode 100644 front/src/pages/Feed.tsx

(limited to 'front/src/pages/Feed.tsx')

diff --git a/front/src/pages/Feed.tsx b/front/src/pages/Feed.tsx
new file mode 100644
index 0000000..e29033e
--- /dev/null
+++ b/front/src/pages/Feed.tsx
@@ -0,0 +1,104 @@
+// import spinner from "@/assets/icons/spinner.svg";
+import "@/styles/trill.css";
+import UserFeed from "./User";
+import PostList from "@/components/feed/PostList";
+import useLocalState from "@/state/state";
+import { useParams, useLocation } from "wouter";
+import spinner from "@/assets/triangles.svg";
+import { useState } from "react";
+import Composer from "@/components/feed/Composer";
+// import UserFeed from "./User";
+import { P404 } from "@/Router";
+import { useQuery } from "@tanstack/react-query";
+import { isValidPatp } from "urbit-ob";
+import { eventsToFc } from "@/logic/nostril";
+
+type FeedType = "global" | "following" | "nostr";
+function Loader() {
+  // const { api } = useLocalState();
+  const params = useParams();
+  console.log({ params });
+  // const [loc, navigate] = useLocation();
+  // console.log({ loc });
+  // const our = api!.airlock.ship;
+  if (params.taip === "global") return <FeedPage t={"global"} />;
+  if (params.taip === "nostr") return <FeedPage t={"nostr"} />;
+  // else if (param === FeedType.Rumors) return <Rumors />;
+  // else if (param === FeedType.Home) return <UserFeed p={our} />;
+  else if (isValidPatp(params.taip!)) return <UserFeed p={params.taip!} />;
+  else return <P404 />;
+}
+function FeedPage({ t }: { t: FeedType }) {
+  const [active, setActive] = useState<FeedType>(t);
+  return (
+    <main>
+      <div id="top-tabs">
+        <div
+          className={active === "global" ? "active" : ""}
+          onClick={() => setActive("global")}
+        >
+          Global
+        </div>
+        <div
+          className={active === "following" ? "active" : ""}
+          onClick={() => setActive("following")}
+        >
+          Following
+        </div>
+        <div
+          className={active === "nostr" ? "active" : ""}
+          onClick={() => setActive("nostr")}
+        >
+          Nostr
+        </div>
+      </div>
+      <div id="feed-proper">
+        <Composer />
+        {active === "global" ? (
+          <Global />
+        ) : active === "following" ? (
+          <Global />
+        ) : active === "nostr" ? (
+          <Nostr />
+        ) : null}
+      </div>
+    </main>
+  );
+}
+//   {active === "global" ? (
+//     <Global />
+//   ) : active === "following" ? (
+//     <Global />
+//   ) : (
+//     <Global />
+//   )}
+
+function Global() {
+  // const { api } = useLocalState();
+  // const { isPending, data, refetch } = useQuery({
+  //   queryKey: ["globalFeed"],
+  //   queryFn: () => {
+  //     return api!.scryFeed(null, null);
+  //   },
+  // });
+  // console.log(data, "scry feed data");
+  // if (isPending) return <img className="x-center" src={spinner} />;
+  // else if ("bucun" in data) return <p>Error</p>;
+  // else return <Inner data={data} refetch={refetch} />;
+  return <p>Error</p>;
+}
+function Nostr() {
+  const { relays } = useLocalState();
+  const feed = eventsToFc(relays);
+  console.log({ feed });
+  const refetch = () => feed;
+  return <PostList data={feed} refetch={refetch} />;
+}
+
+export default Loader;
+// TODO
+type MixFeed = any;
+
+function Inner({ data, refetch }: { data: MixFeed; refetch: Function }) {
+  return <PostList data={data.mix.fc} refetch={refetch} />;
+}
-- 
cgit v1.2.3

