From e722f74665d79c4c20dbf49f7b11fe883f22c434 Mon Sep 17 00:00:00 2001 From: OFF0 Date: Wed, 2 Aug 2023 12:41:23 +0200 Subject: [PATCH] profile: keep track of replies before the map that keeps track of all replies-to ids was not in the same scope of the subscription but genereated in each callback. --- src/subscriptions.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/subscriptions.ts b/src/subscriptions.ts index 2a5b8ae..d8d6e6d 100644 --- a/src/subscriptions.ts +++ b/src/subscriptions.ts @@ -148,6 +148,7 @@ export const subProfile = ( pubkey: string, onEvent: SubCallback, ) => { + console.info(`subscribe to profile ${pubkey}`); unsubAll(); sub({ cb: onEvent, @@ -155,13 +156,17 @@ export const subProfile = ( authors: [pubkey], kinds: [0], limit: 1, - } + }, }); + + const repliesTo = new Set(); // get notes for profile sub({ cb: (evt, relay) => { - const repliesTo = new Set(); - if (evt.tags.some(hasEventTag) && !evt.tags.some(isMention)) { + if ( + evt.tags.some(hasEventTag) + && !evt.tags.some(isMention) + ) { const note = getReplyTo(evt); if (note && !repliesTo.has(note)) { repliesTo.add(note); @@ -173,7 +178,7 @@ export const subProfile = ( kinds: [1], limit: 1, } - }) + }); } } onEvent(evt, relay);