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/components/post/Footer.tsx | 62 +++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 26 deletions(-) (limited to 'front/src/components/post/Footer.tsx') diff --git a/front/src/components/post/Footer.tsx b/front/src/components/post/Footer.tsx index d16f4fc..5b79da0 100644 --- a/front/src/components/post/Footer.tsx +++ b/front/src/components/post/Footer.tsx @@ -13,33 +13,33 @@ function Footer({ poast, refetch }: PostProps) { const [_showMenu, setShowMenu] = useState(false); const [location, navigate] = useLocation(); const [reposting, _setReposting] = useState(false); - const { api, setComposerData, setModal, addNotification } = useLocalState((s) => ({ - api: s.api, - setComposerData: s.setComposerData, - setModal: s.setModal, - addNotification: s.addNotification, - })); + const { api, setComposerData, setModal, addNotification } = useLocalState( + (s) => ({ + api: s.api, + setComposerData: s.setComposerData, + setModal: s.setModal, + addNotification: s.addNotification, + }), + ); const our = api!.airlock.our!; function doReply(e: React.MouseEvent) { + console.log("do reply"); e.stopPropagation(); + e.preventDefault(); setComposerData({ type: "reply", post: { trill: poast } }); - // Only add notification if replying to someone else's post - if (poast.author !== our) { - addNotification({ - type: "reply", - from: our, - message: `You replied to ${poast.author}'s post`, - postId: poast.id, - }); - } + // Scroll to top where composer is located + window.scrollTo({ top: 0, behavior: "smooth" }); + // Focus will be handled by the composer component } function doQuote(e: React.MouseEvent) { e.stopPropagation(); + e.preventDefault(); setComposerData({ type: "quote", post: { trill: poast }, }); - navigate("/composer"); + // Scroll to top where composer is located + window.scrollTo({ top: 0, behavior: "smooth" }); } const childrenCount = poast.children ? poast.children.length @@ -49,6 +49,7 @@ function Footer({ poast, refetch }: PostProps) { const myRP = poast.engagement.shared.find((r) => r.pid.ship === our); async function cancelRP(e: React.MouseEvent) { e.stopPropagation(); + e.preventDefault(); const r = await api!.deletePost(our); if (r) toast.success("Repost deleted"); refetch(); @@ -57,6 +58,7 @@ function Footer({ poast, refetch }: PostProps) { async function sendRP(e: React.MouseEvent) { // TODO update backend because contents are only markdown now e.stopPropagation(); + e.preventDefault(); // const c = [ // { // ref: { @@ -85,6 +87,7 @@ function Footer({ poast, refetch }: PostProps) { } function doReact(e: React.MouseEvent) { e.stopPropagation(); + e.preventDefault(); const modal = ; setModal(modal); } @@ -138,13 +141,17 @@ function Footer({ poast, refetch }: PostProps) { {displayCount(childrenCount)} - +
+ +
{displayCount(poast.engagement.quoted.length)} - +
+ +
...

) : myRP ? ( - +
+ +
) : ( - +
+ +
)}
-- cgit v1.2.3