From 0f1bd83f905bdbe01455c4b1a013b95f9f7926d9 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Mon, 20 Oct 2025 20:51:32 +0200 Subject: [PATCH] fix redundant video --- src/components/Note/VideoNote.tsx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/components/Note/VideoNote.tsx b/src/components/Note/VideoNote.tsx index a5debe0..8301e45 100644 --- a/src/components/Note/VideoNote.tsx +++ b/src/components/Note/VideoNote.tsx @@ -6,13 +6,32 @@ import MediaPlayer from '../MediaPlayer' export default function VideoNote({ event, className }: { event: Event; className?: string }) { const videoInfos = useMemo(() => getImetaInfosFromEvent(event), [event]) + + // Extract URLs from content to avoid duplicate rendering + const contentUrls = useMemo(() => { + const content = event.content || '' + const urlMatches = content.match(/https?:\/\/[^\s]+/g) || [] + return urlMatches.map(url => { + try { + return new URL(url).href + } catch { + return url + } + }) + }, [event.content]) return (
- {videoInfos.map((video) => ( - - ))} + {videoInfos + .filter((video) => { + // Only render videos from imeta tags that are not already in the content + const videoUrl = new URL(video.url).href + return !contentUrls.includes(videoUrl) + }) + .map((video) => ( + + ))}
) }