From 7098ce1f20c8c39c7624d0f69c5da73a18efcbb9 Mon Sep 17 00:00:00 2001 From: SnowCait Date: Mon, 16 Oct 2023 23:10:41 +0900 Subject: [PATCH] REQ if exists --- web/src/lib/timelines/MainTimeline.ts | 30 +++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/web/src/lib/timelines/MainTimeline.ts b/web/src/lib/timelines/MainTimeline.ts index 3d7753a3d..8afc9b475 100644 --- a/web/src/lib/timelines/MainTimeline.ts +++ b/web/src/lib/timelines/MainTimeline.ts @@ -31,19 +31,23 @@ export function referencesReqEmit(event: Event): void { } const $eventItemStore = get(eventItemStore); - eventsReq.emit({ - ids: [ - ...new Set([ - ...event.tags - .filter( - ([tagName, id]) => - tagName === 'e' && id !== undefined && !$eventItemStore.has(id) - ) - .map(([, id]) => id), - ...Content.findNotesAndNeventsToIds(event.content) - ]) - ] - }); + const ids = [ + ...new Set([ + ...event.tags + .filter( + ([tagName, id]) => + tagName === 'e' && id !== undefined && !$eventItemStore.has(id) + ) + .map(([, id]) => id), + ...Content.findNotesAndNeventsToIds(event.content) + ]) + ]; + + if (ids.length > 0) { + eventsReq.emit({ + ids + }); + } } rxNostr