3 changed files with 60 additions and 43 deletions
@ -1,29 +1,12 @@ |
|||||||
import { Event } from 'nostr-tools' |
import { Event } from 'nostr-tools' |
||||||
import { useMemo } from 'react' |
|
||||||
import { cleanUrl } from '@/lib/url' |
|
||||||
import { useMediaExtraction } from '@/hooks/useMediaExtraction' |
|
||||||
import Content from '../Content' |
import Content from '../Content' |
||||||
import ImageGallery from '../ImageGallery' |
|
||||||
|
|
||||||
export default function PictureNote({ event, className }: { event: Event; className?: string }) { |
export default function PictureNote({ event, className }: { event: Event; className?: string }) { |
||||||
const { images } = useMediaExtraction(event, event.content) |
// Content component already handles all image rendering (from content and tags)
|
||||||
|
// with proper deduplication, so we don't need to add anything extra
|
||||||
// Extract cleaned URLs from content to avoid duplicate rendering
|
|
||||||
const contentUrls = useMemo(() => { |
|
||||||
const content = event.content || '' |
|
||||||
const urlMatches = content.match(/https?:\/\/[^\s]+/g) || [] |
|
||||||
return new Set(urlMatches.map(url => cleanUrl(url))) |
|
||||||
}, [event.content]) |
|
||||||
|
|
||||||
// Images that don't appear in content (from tags only)
|
|
||||||
const imagesFromTags = useMemo(() => { |
|
||||||
return images.filter(img => !contentUrls.has(img.url)) |
|
||||||
}, [images, contentUrls]) |
|
||||||
|
|
||||||
return ( |
return ( |
||||||
<div className={className}> |
<div className={className}> |
||||||
<Content event={event} /> |
<Content event={event} /> |
||||||
{imagesFromTags.length > 0 && <ImageGallery images={imagesFromTags} className="mt-2" />} |
|
||||||
</div> |
</div> |
||||||
) |
) |
||||||
} |
} |
||||||
|
|||||||
@ -1,31 +1,12 @@ |
|||||||
import { Event } from 'nostr-tools' |
import { Event } from 'nostr-tools' |
||||||
import { useMemo } from 'react' |
|
||||||
import { cleanUrl } from '@/lib/url' |
|
||||||
import { useMediaExtraction } from '@/hooks/useMediaExtraction' |
|
||||||
import Content from '../Content' |
import Content from '../Content' |
||||||
import MediaPlayer from '../MediaPlayer' |
|
||||||
|
|
||||||
export default function VideoNote({ event, className }: { event: Event; className?: string }) { |
export default function VideoNote({ event, className }: { event: Event; className?: string }) { |
||||||
const { videos } = useMediaExtraction(event, event.content) |
// Content component already handles all media rendering (from content and tags)
|
||||||
|
// with proper deduplication, so we don't need to add anything extra
|
||||||
// Extract cleaned URLs from content to avoid duplicate rendering
|
|
||||||
const contentUrls = useMemo(() => { |
|
||||||
const content = event.content || '' |
|
||||||
const urlMatches = content.match(/https?:\/\/[^\s]+/g) || [] |
|
||||||
return new Set(urlMatches.map(url => cleanUrl(url))) |
|
||||||
}, [event.content]) |
|
||||||
|
|
||||||
// Videos that don't appear in content (from tags only)
|
|
||||||
const videosFromTags = useMemo(() => { |
|
||||||
return videos.filter(video => !contentUrls.has(video.url)) |
|
||||||
}, [videos, contentUrls]) |
|
||||||
|
|
||||||
return ( |
return ( |
||||||
<div className={className}> |
<div className={className}> |
||||||
<Content event={event} /> |
<Content event={event} /> |
||||||
{videosFromTags.map((video) => ( |
|
||||||
<MediaPlayer src={video.url} key={video.url} className="mt-2" mustLoad={false} /> |
|
||||||
))} |
|
||||||
</div> |
</div> |
||||||
) |
) |
||||||
} |
} |
||||||
|
|||||||
Loading…
Reference in new issue