From 985fa2f7c99832cdf3c3351d2273c8fd05402b78 Mon Sep 17 00:00:00 2001 From: polwex Date: Wed, 17 Sep 2025 21:45:18 +0700 Subject: basic comms working --- front/src/components/post/Body.tsx | 4 ++-- front/src/components/post/Card.tsx | 7 +++++-- front/src/components/post/External.tsx | 3 +-- front/src/components/post/Footer.tsx | 24 +++++++++++++----------- front/src/components/post/Header.tsx | 2 +- front/src/components/post/Loader.tsx | 2 +- front/src/components/post/Post.tsx | 4 ++-- front/src/components/post/Reactions.tsx | 4 ++-- front/src/components/post/wrappers/Nostr.tsx | 2 +- front/src/components/post/wrappers/NostrIcon.tsx | 9 ++++++--- 10 files changed, 34 insertions(+), 27 deletions(-) (limited to 'front/src/components/post') diff --git a/front/src/components/post/Body.tsx b/front/src/components/post/Body.tsx index 2e4e2f8..e8b659c 100644 --- a/front/src/components/post/Body.tsx +++ b/front/src/components/post/Body.tsx @@ -6,7 +6,7 @@ import type { Media as MediaType, ExternalContent, } from "@/types/trill"; -import crow from "@/assets/icons/crow.svg"; +import Icon from "@/components/Icon"; import type { PostProps } from "./Post"; import Media from "./Media"; import JSONContent, { YoutubeSnippet } from "./External"; @@ -168,7 +168,7 @@ function Ref({ r, nest }: { r: Reference; nest: number }) { nest: nest + 1, className: "quote-in-post", })(Quote); - return {comp}; + return {comp}; } return <>; } diff --git a/front/src/components/post/Card.tsx b/front/src/components/post/Card.tsx index 37f4911..9309423 100644 --- a/front/src/components/post/Card.tsx +++ b/front/src/components/post/Card.tsx @@ -1,8 +1,11 @@ -export default function ({ children, logo, cn}: { cn?: string; logo: string; children: any }) { +import Icon from "@/components/Icon"; +import type { IconName } from "@/components/Icon"; + +export default function ({ children, logo, cn}: { cn?: string; logo: IconName; children: any }) { const className = "trill-post-card" + (cn ? ` ${cn}`: "") return (
- + {children}
); diff --git a/front/src/components/post/External.tsx b/front/src/components/post/External.tsx index 0ea1500..d52aec7 100644 --- a/front/src/components/post/External.tsx +++ b/front/src/components/post/External.tsx @@ -1,5 +1,4 @@ import type { ExternalContent } from "@/types/trill"; -import youtube from "@/assets/icons/youtube.svg"; import Card from "./Card"; interface JSONProps { @@ -32,7 +31,7 @@ export function YoutubeSnippet({ href, id }: { href: string; id: string }) { const thumbnail = `https://i.ytimg.com/vi/${id}/hqdefault.jpg`; // todo styiling return ( - + diff --git a/front/src/components/post/Footer.tsx b/front/src/components/post/Footer.tsx index 3b48241..3e4bbdc 100644 --- a/front/src/components/post/Footer.tsx +++ b/front/src/components/post/Footer.tsx @@ -1,7 +1,5 @@ import type { PostProps } from "./Post"; -import reply from "@/assets/icons/reply.svg"; -import quote from "@/assets/icons/quote.svg"; -import repost from "@/assets/icons/rt.svg"; +import Icon from "@/components/Icon"; import { useState } from "react"; import useLocalState from "@/state/state"; import { useLocation } from "wouter"; @@ -15,7 +13,11 @@ function Footer({ poast, refetch }: PostProps) { const [_showMenu, setShowMenu] = useState(false); const [location, navigate] = useLocation(); const [reposting, _setReposting] = useState(false); - const { api, setComposerData, setModal } = useLocalState(); + const { api, setComposerData, setModal } = useLocalState((s) => ({ + api: s.api, + setComposerData: s.setComposerData, + setModal: s.setModal, + })); const our = api!.airlock.our!; function doReply(e: React.MouseEvent) { e.stopPropagation(); @@ -126,13 +128,13 @@ function Footer({ poast, refetch }: PostProps) { {displayCount(childrenCount)} - +
{displayCount(poast.engagement.quoted.length)} - +
...

) : myRP ? ( - ) : ( - + )}
diff --git a/front/src/components/post/Header.tsx b/front/src/components/post/Header.tsx index e541fa5..4e72fe8 100644 --- a/front/src/components/post/Header.tsx +++ b/front/src/components/post/Header.tsx @@ -4,7 +4,7 @@ import { useLocation } from "wouter"; import useLocalState from "@/state/state"; function Header(props: PostProps) { const [_, navigate] = useLocation(); - const { profiles } = useLocalState(); + const profiles = useLocalState((s) => s.profiles); const profile = profiles.get(props.poast.author); // console.log("profile", profile); // console.log(props.poast.author.length, "length"); diff --git a/front/src/components/post/Loader.tsx b/front/src/components/post/Loader.tsx index f3c4715..a23bea1 100644 --- a/front/src/components/post/Loader.tsx +++ b/front/src/components/post/Loader.tsx @@ -14,7 +14,7 @@ function PostData(props: { nest?: number; // nested quotes className?: string; }) { - const { api } = useLocalState(); + const { api } = useLocalState((s) => ({ api: s.api })); const { host, id, nest } = props; const [enest, setEnest] = useState(nest); useEffect(() => { diff --git a/front/src/components/post/Post.tsx b/front/src/components/post/Post.tsx index e61efb0..277c119 100644 --- a/front/src/components/post/Post.tsx +++ b/front/src/components/post/Post.tsx @@ -47,7 +47,7 @@ export default Post; function TrillPost(props: PostProps) { const { poast, profile, fake } = props; - const { setModal } = useLocalState(); + const setModal = useLocalState((s) => s.setModal); const [_, navigate] = useLocation(); function openThread(_e: React.MouseEvent) { const sel = window.getSelection()?.toString(); @@ -64,7 +64,7 @@ function TrillPost(props: PostProps) {
) : (
- +
); return ( diff --git a/front/src/components/post/Reactions.tsx b/front/src/components/post/Reactions.tsx index 58662cd..aabab61 100644 --- a/front/src/components/post/Reactions.tsx +++ b/front/src/components/post/Reactions.tsx @@ -14,7 +14,7 @@ import soy from "@/assets/reacts/soy.png"; import chad from "@/assets/reacts/chad.png"; import pika from "@/assets/reacts/pika.png"; import facepalm from "@/assets/reacts/facepalm.png"; -import emoji from "@/assets/icons/emoji.svg"; +import Icon from "@/components/Icon"; import emojis from "@/logic/emojis.json"; import Modal from "../modals/Modal"; import useLocalState from "@/state/state"; @@ -93,7 +93,7 @@ export function stringToReact(s: string) { if (s === "pepesad") return ; if (s === "") - return ; + return ; if (s === "cringe") return ; if (s === "cry") return ; if (s === "crywojak") return ; diff --git a/front/src/components/post/wrappers/Nostr.tsx b/front/src/components/post/wrappers/Nostr.tsx index bdc5ba9..2782fb8 100644 --- a/front/src/components/post/wrappers/Nostr.tsx +++ b/front/src/components/post/wrappers/Nostr.tsx @@ -4,7 +4,7 @@ import useLocalState from "@/state/state"; export default NostrPost; function NostrPost({ data }: { data: NostrPost }) { - const { profiles } = useLocalState(); + const { profiles } = useLocalState((s) => ({ profiles: s.profiles })); const profile = profiles.get(data.event.pubkey); return ; diff --git a/front/src/components/post/wrappers/NostrIcon.tsx b/front/src/components/post/wrappers/NostrIcon.tsx index 0c368fb..30fbfe9 100644 --- a/front/src/components/post/wrappers/NostrIcon.tsx +++ b/front/src/components/post/wrappers/NostrIcon.tsx @@ -1,9 +1,12 @@ -import nostrIcon from "@/assets/icons/nostr.svg"; +import Icon from "@/components/Icon"; import useLocalState from "@/state/state"; import toast from "react-hot-toast"; import type { Poast } from "@/types/trill"; export default function ({ poast }: { poast: Poast }) { - const { relays, api, keys } = useLocalState(); + const { relays, api } = useLocalState((s) => ({ + relays: s.relays, + api: s.api, + })); async function sendToRelay(e: React.MouseEvent) { e.stopPropagation(); @@ -16,7 +19,7 @@ export default function ({ poast }: { poast: Poast }) { return (
- +
); } -- cgit v1.2.3