import "./Note.css"; import { useEffect, useState } from "react"; import { useSelector } from "react-redux"; import moment from "moment"; import { Link, useNavigate } from "react-router-dom"; import { faHeart, faReply, faInfo } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import Event from "../nostr/Event"; import ProfileImage from "./ProfileImage"; import useEventPublisher from "../pages/feed/EventPublisher"; const UrlRegex = /((?:http|ftp|https):\/\/(?:[\w+?\.\w+])+(?:[a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?)/; const FileExtensionRegex = /\.([\w]+)$/; const MentionRegex = /(#\[\d+\])/g; export default function Note(props) { const navigate = useNavigate(); const data = props.data; const dataEvent = props["data-ev"]; const reactions = props.reactions; const publisher = useEventPublisher(); const [sig, setSig] = useState(false); const users = useSelector(s => s.users?.users); const ev = dataEvent ?? Event.FromObject(data); useEffect(() => { if (sig === false) { verifyEvent(); } }, []); async function verifyEvent() { let res = await ev.Verify(); setSig(res); } function goToEvent(e, id) { if (!window.location.pathname.startsWith("/e/")) { e.stopPropagation(); navigate(`/e/${id}`); } } function replyTag() { let thread = ev.GetThread(); if (thread === null) { return null; } let replyId = thread?.ReplyTo?.Event; let mentions = thread?.PubKeys?.map(a => [a, users[a]])?.map(a => a[1]?.name ?? a[0].substring(0, 8)); return (
{ev.Id}
Kind: {ev.Kind}
Content: {ev.Content}> ); } return (