From b1d68ac307ed87d63e83820cbdf843fff0fd9f7f Mon Sep 17 00:00:00 2001 From: polwex Date: Thu, 11 Sep 2025 01:48:14 +0700 Subject: init --- front/src/pages/Feed.tsx | 104 +++++++++++++++++++++++++++++++++++++++++++ front/src/pages/Settings.tsx | 92 ++++++++++++++++++++++++++++++++++++++ front/src/pages/User.tsx | 18 ++++++++ 3 files changed, 214 insertions(+) create mode 100644 front/src/pages/Feed.tsx create mode 100644 front/src/pages/Settings.tsx create mode 100644 front/src/pages/User.tsx (limited to 'front/src/pages') 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 ; + if (params.taip === "nostr") return ; + // else if (param === FeedType.Rumors) return ; + // else if (param === FeedType.Home) return ; + else if (isValidPatp(params.taip!)) return ; + else return ; +} +function FeedPage({ t }: { t: FeedType }) { + const [active, setActive] = useState(t); + return ( +
+
+
setActive("global")} + > + Global +
+
setActive("following")} + > + Following +
+
setActive("nostr")} + > + Nostr +
+
+
+ + {active === "global" ? ( + + ) : active === "following" ? ( + + ) : active === "nostr" ? ( + + ) : null} +
+
+ ); +} +// {active === "global" ? ( +// +// ) : active === "following" ? ( +// +// ) : ( +// +// )} + +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 ; + // else if ("bucun" in data) return

Error

; + // else return ; + return

Error

; +} +function Nostr() { + const { relays } = useLocalState(); + const feed = eventsToFc(relays); + console.log({ feed }); + const refetch = () => feed; + return ; +} + +export default Loader; +// TODO +type MixFeed = any; + +function Inner({ data, refetch }: { data: MixFeed; refetch: Function }) { + return ; +} diff --git a/front/src/pages/Settings.tsx b/front/src/pages/Settings.tsx new file mode 100644 index 0000000..e0f1da9 --- /dev/null +++ b/front/src/pages/Settings.tsx @@ -0,0 +1,92 @@ +import useLocalState from "@/state/state"; +import type { UserProfile } from "@/types/nostril"; +import { useState } from "react"; + +function Settings() { + const { UISettings, keys, profiles, relays, api } = useLocalState(); + const [newRelay, setNewRelay] = useState(""); + async function saveSetting( + bucket: string, + key: string, + value: string | boolean | number | string[], + ) { + const json = { + "put-entry": { + desk: "trill", + "bucket-key": bucket, + "entry-key": key, + value, + }, + }; + // const res = await poke("settings", "settings-event", json); + // if (res) refetchSettings(); + } + async function removeRelay(url: string) { + console.log({ url }); + } + async function addNewRelay() { + // + // await addnr(newRelay); + } + async function removeProfile(pubkey: string) { + api!.removeKey(pubkey); + } + async function createProfile() { + // + api!.createKey(); + } + + return ( +
+

Settings

+
+ + {keys.map((k) => { + const profile = profiles.get(k); + const profileDiv = !profile ? ( +
+
Pubkey: {k}
+

No profile set

) +
+ ) : ( +
+ {profile.picture && } +
Name: {profile.name}
+
Pubkey: {k}
+
About: {profile.about}
+ +
+ ); + return ( +
+ {profileDiv} +
+ ); + })} +
+ +
+
+
+ + {Object.keys(relays).map((r) => ( + // TODO: add connect button to connect and disc to relay one by one +
+
{r}
+ +
+ ))} +
+ + setNewRelay(e.target.value)} + /> + +
+
+
+ ); +} +export default Settings; diff --git a/front/src/pages/User.tsx b/front/src/pages/User.tsx new file mode 100644 index 0000000..fc727e4 --- /dev/null +++ b/front/src/pages/User.tsx @@ -0,0 +1,18 @@ +// import spinner from "@/assets/icons/spinner.svg"; +import PostList from "@/components/feed/PostList"; +import useLocalState from "@/state/state"; +import type { Ship } from "@/types/urbit"; + +function UserFeed({ p }: { p: Ship }) { + const { api, following } = useLocalState(); + const feed = following.get(api!.airlock.our!); + const refetch = () => feed; + if (p === api!.airlock.our) + return ( +
+ +
+ ); +} + +export default UserFeed; -- cgit v1.2.3