diff options
| author | polwex <polwex@sortug.com> | 2025-11-18 08:32:45 +0700 |
|---|---|---|
| committer | polwex <polwex@sortug.com> | 2025-11-18 08:32:45 +0700 |
| commit | 7706acaafa89691dba33c216e6287a8405c4c302 (patch) | |
| tree | 504d49fd289c6f4f6f5494395ddd4089a057efc9 /gui/src/components/post/wrappers/NostrIcon.tsx | |
| parent | b3379cc108d6eed98cb0010e6f1ddca94aba83a2 (diff) | |
gui fixes to nostr post rendering, added nostr-tools lib for primal compatibility
Diffstat (limited to 'gui/src/components/post/wrappers/NostrIcon.tsx')
| -rw-r--r-- | gui/src/components/post/wrappers/NostrIcon.tsx | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gui/src/components/post/wrappers/NostrIcon.tsx b/gui/src/components/post/wrappers/NostrIcon.tsx index 30fbfe9..f39d689 100644 --- a/gui/src/components/post/wrappers/NostrIcon.tsx +++ b/gui/src/components/post/wrappers/NostrIcon.tsx @@ -2,14 +2,23 @@ import Icon from "@/components/Icon"; import useLocalState from "@/state/state"; import toast from "react-hot-toast"; import type { Poast } from "@/types/trill"; +import { generateNevent } from "@/logic/nostr"; export default function ({ poast }: { poast: Poast }) { const { relays, api } = useLocalState((s) => ({ relays: s.relays, api: s.api, })); - async function sendToRelay(e: React.MouseEvent) { + async function handleClick(e: React.MouseEvent) { e.stopPropagation(); + if (poast.event) { + const nevent = generateNevent(poast.event); + console.log({ nevent }); + const href = `https://primal.net/e/${nevent}`; + window.open(href, "_blank"); + } else sendToRelay(e); + } + async function sendToRelay(e: React.MouseEvent) { // const urls = Object.keys(relays); await api!.relayPost(poast.host, poast.id, urls); @@ -18,8 +27,10 @@ export default function ({ poast }: { poast: Poast }) { // TODO round up all helpers return ( - <div className="icon" role="link" onMouseUp={sendToRelay}> + <div className="icon" role="link" onMouseUp={handleClick}> <Icon name="nostr" size={20} title="relay to nostr" /> </div> ); } + +// npub1w8k2hk9kkv653cr4luqmx9tglldpn59vy7yqvlvex2xxmeygt96s4dlh8p |
