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 1 year ago
parent ea21e47cad
commit e722f74665
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -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<string>();
// get notes for profile
sub({
cb: (evt, relay) => {
const repliesTo = new Set<string>();
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);

Loading…
Cancel
Save