import React from 'react'; import { useProfile } from "nostr-react"; import { nip19, } from "nostr-tools"; import { Card, SmallCardContent, } from "@/components/ui/card" import Image from 'next/image'; import Link from 'next/link'; import { PlayIcon, StackIcon, VideoIcon } from '@radix-ui/react-icons'; interface NoteCardProps { pubkey: string; text: string; eventId: string; tags: string[][]; event: any; linkToNote: boolean; } const QuickViewNoteCard: React.FC = ({ pubkey, text, eventId, tags, event, linkToNote }) => { const { data: userData } = useProfile({ pubkey, }); const title = userData?.username || userData?.display_name || userData?.name || userData?.npub || nip19.npubEncode(pubkey); text = text.replaceAll('\n', ' '); const imageSrc = text.match(/https?:\/\/[^ ]*\.(png|jpg|gif|jpeg)/g); const videoSrc = text.match(/https?:\/\/[^ ]*\.(mp4|webm|mov)/g); const textWithoutImage = text.replace(/https?:\/\/.*\.(?:png|jpg|gif|mp4|webm|mov|jpeg)/g, ''); const createdAt = new Date(event.created_at * 1000); const hrefProfile = `/profile/${nip19.npubEncode(pubkey)}`; const profileImageSrc = userData?.picture || "https://robohash.org/" + pubkey; const encodedNoteId = nip19.noteEncode(event.id) const card = (
{imageSrc && imageSrc.length > 1 && !videoSrc ? (
{text}
) : imageSrc && imageSrc.length > 0 ? (
{videoSrc && videoSrc.length > 0 &&
} {text}
) : videoSrc && videoSrc.length > 0 ? (
) : null}
); return ( <> {linkToNote ? ( {card} ) : ( card )} ); } export default QuickViewNoteCard;