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.
pull/81/head
OFF0 10 months ago
parent ea21e47cad
commit e722f74665
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -148,6 +148,7 @@ export const subProfile = (
pubkey: string, pubkey: string,
onEvent: SubCallback, onEvent: SubCallback,
) => { ) => {
console.info(`subscribe to profile ${pubkey}`);
unsubAll(); unsubAll();
sub({ sub({
cb: onEvent, cb: onEvent,
@ -155,13 +156,17 @@ export const subProfile = (
authors: [pubkey], authors: [pubkey],
kinds: [0], kinds: [0],
limit: 1, limit: 1,
} },
}); });
const repliesTo = new Set<string>();
// get notes for profile // get notes for profile
sub({ sub({
cb: (evt, relay) => { cb: (evt, relay) => {
const repliesTo = new Set<string>(); if (
if (evt.tags.some(hasEventTag) && !evt.tags.some(isMention)) { evt.tags.some(hasEventTag)
&& !evt.tags.some(isMention)
) {
const note = getReplyTo(evt); const note = getReplyTo(evt);
if (note && !repliesTo.has(note)) { if (note && !repliesTo.has(note)) {
repliesTo.add(note); repliesTo.add(note);
@ -173,7 +178,7 @@ export const subProfile = (
kinds: [1], kinds: [1],
limit: 1, limit: 1,
} }
}) });
} }
} }
onEvent(evt, relay); onEvent(evt, relay);

Loading…
Cancel
Save