From 199abeba1bffcb4b6a877e7913a8fd8dc823a9a4 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sat, 6 Dec 2025 05:38:45 +0100 Subject: [PATCH] filter out non-whitlisted events from the relay feed --- src/components/NoteList/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/NoteList/index.tsx b/src/components/NoteList/index.tsx index ec3b152..3b7b6bd 100644 --- a/src/components/NoteList/index.tsx +++ b/src/components/NoteList/index.tsx @@ -136,6 +136,8 @@ const NoteList = forwardRef( const idSet = new Set() return events.slice(0, showCount).filter((evt) => { + // Filter out events that aren't in the whitelisted kinds + if (!showKinds.includes(evt.kind)) return false if (shouldHideEvent(evt)) return false const id = isReplaceableEvent(evt.kind) ? getReplaceableCoordinateFromEvent(evt) : evt.id @@ -145,12 +147,14 @@ const NoteList = forwardRef( idSet.add(id) return true }) - }, [events, showCount, shouldHideEvent]) + }, [events, showCount, shouldHideEvent, showKinds]) const filteredNewEvents = useMemo(() => { const idSet = new Set() return newEvents.filter((event: Event) => { + // Filter out events that aren't in the whitelisted kinds + if (!showKinds.includes(event.kind)) return false if (shouldHideEvent(event)) return false const id = isReplaceableEvent(event.kind) @@ -162,7 +166,7 @@ const NoteList = forwardRef( idSet.add(id) return true }) - }, [newEvents, shouldHideEvent]) + }, [newEvents, shouldHideEvent, showKinds]) const scrollToTop = (behavior: ScrollBehavior = 'instant') => { setTimeout(() => { @@ -217,6 +221,10 @@ const NoteList = forwardRef( } }, onNew: (event) => { + // Filter out events that aren't in the whitelisted kinds + if (!showKinds.includes(event.kind)) { + return + } if (pubkey && event.pubkey === pubkey) { // If the new event is from the current user, insert it directly into the feed setEvents((oldEvents) =>