From f0df4c7297a05bd592d8717b8997284c80fd0500 Mon Sep 17 00:00:00 2001 From: polwex Date: Wed, 17 Sep 2025 15:56:00 +0700 Subject: argh --- front/src/components/feed/Footer.tsx | 237 ----------------------------------- 1 file changed, 237 deletions(-) delete mode 100644 front/src/components/feed/Footer.tsx (limited to 'front/src/components/feed/Footer.tsx') diff --git a/front/src/components/feed/Footer.tsx b/front/src/components/feed/Footer.tsx deleted file mode 100644 index 938a8c7..0000000 --- a/front/src/components/feed/Footer.tsx +++ /dev/null @@ -1,237 +0,0 @@ -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 { useState } from "react"; -import useLocalState from "@/state/state"; -import { useLocation } from "wouter"; -import { displayCount } from "@/logic/utils"; -import { TrillReactModal, stringToReact } from "./Reactions"; -import toast from "react-hot-toast"; -import NostrIcon from "./NostrIcon"; -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 our = api!.airlock.our!; - function doReply(e: React.MouseEvent) { - e.stopPropagation(); - setComposerData({ type: "reply", post: { service: "trill", post: poast } }); - navigate("/composer"); - } - function doQuote(e: React.MouseEvent) { - e.stopPropagation(); - setComposerData({ - type: "quote", - post: { service: "trill", post: poast }, - }); - navigate("/composer"); - } - const childrenCount = poast.children - ? poast.children.length - ? poast.children.length - : Object.keys(poast.children).length - : 0; - const myRP = poast.engagement.shared.find((r) => r.pid.ship === our); - async function cancelRP(e: React.MouseEvent) { - e.stopPropagation(); - const r = await api!.deletePost(our); - if (r) toast.success("Repost deleted"); - refetch(); - if (location.includes(poast.id)) navigate("/"); - } - async function sendRP(e: React.MouseEvent) { - // TODO update backend because contents are only markdown now - e.stopPropagation(); - // const c = [ - // { - // ref: { - // type: "trill", - // ship: poast.host, - // path: `/${poast.id}`, - // }, - // }, - // ]; - // const post: SentPoast = { - // host: our, - // author: our, - // thread: null, - // parent: null, - // contents: input, - // read: openLock, - // write: openLock, - // tags: [], // TODO - // }; - // const r = await api!.addPost(post, false); - // setReposting(true); - // if (r) { - // setReposting(false); - // toast.success("Your post was published"); - // } - } - function doReact(e: React.MouseEvent) { - e.stopPropagation(); - const modal = ; - setModal(modal); - } - function showReplyCount() { - if (poast.children[0]) fetchAndShow(); // Flatpoast - // else { - // const authors = Object.keys(poast.children).map( - // (i) => poast.children[i].post.author - // ); - // setEngagement({ type: "replies", ships: authors }, poast); - // } - } - async function fetchAndShow() { - // let authors = []; - // for (let i of poast.children as string[]) { - // const res = await scrypoastFull(poast.host, i); - // if (res) - // authors.push(res.post.author || "deleter"); - // } - // setEngagement({ type: "replies", ships: authors }, poast); - } - function showRepostCount() { - // const ships = poast.engagement.shared.map((entry) => entry.host); - // setEngagement({ type: "reposts", ships: ships }, poast); - } - function showQuoteCount() { - // setEngagement({ type: "quotes", quotes: poast.engagement.quoted }, poast); - } - function showReactCount() { - // setEngagement({ type: "reacts", reacts: poast.engagement.reacts }, poast); - } - - const mostCommonReact = Object.values(poast.engagement.reacts).reduce( - (acc: any, item) => { - if (!acc.counts[item]) acc.counts[item] = 0; - acc.counts[item] += 1; - if (!acc.winner || acc.counts[item] > acc.counts[acc.winner]) - acc.winner = item; - return acc; - }, - { counts: {}, winner: "" }, - ).winner; - const reactIcon = stringToReact(mostCommonReact); - - // TODO round up all helpers - - return ( -
-
-
- - {displayCount(childrenCount)} - - -
-
- - {displayCount(poast.engagement.quoted.length)} - - -
-
- - {displayCount(poast.engagement.shared.length)} - - {reposting ? ( -

...

- ) : myRP ? ( - - ) : ( - - )} -
-
- - {displayCount(Object.keys(poast.engagement.reacts).length)} - - {reactIcon} -
- -
-
- ); -} -export default Footer; - -// function Menu({ -// poast, -// setShowMenu, -// refetch, -// }: { -// poast: Poast; -// setShowMenu: Function; -// refetch: Function; -// }) { -// const ref = useRef(null); -// const [location, navigate] = useLocation(); -// // TODO this is a mess and the event still propagates -// useEffect(() => { -// const checkIfClickedOutside = (e: any) => { -// e.stopPropagation(); -// if (ref && ref.current && !ref.current.contains(e.target)) -// setShowMenu(false); -// }; -// document.addEventListener("mousedown", checkIfClickedOutside); -// return () => { -// document.removeEventListener("mousedown", checkIfClickedOutside); -// }; -// }, []); -// const { our, setModal, setAlert } = useLocalState(); -// const mine = our === poast.host || our === poast.author; -// async function doDelete(e: React.MouseEvent) { -// e.stopPropagation(); -// deletePost(poast.host, poast.id); -// setAlert("Post deleted"); -// setShowMenu(false); -// refetch(); -// if (location.includes(poast.id)) navigate("/"); -// } -// async function copyLink(e: React.MouseEvent) { -// e.stopPropagation(); -// const link = trillPermalink(poast); -// await navigator.clipboard.writeText(link); -// // some alert -// setShowMenu(false); -// } -// function openStats(e: React.MouseEvent) { -// e.stopPropagation(); -// e.preventDefault(); -// const m = setModal(null)} />; -// setModal(m); -// } -// return ( -//
-// {/*

Share to Groups

*/} -//

-// See Stats -//

-//

-// Permalink -//

-// {mine && ( -//

-// Delete Post -//

-// )} -//
-// ); -// } -- cgit v1.2.3