Avoid attempting to unwrap the same event multiple times in a single page load

This commit is contained in:
Jon Staab
2024-11-19 10:24:45 -08:00
parent e5fd172994
commit 6a646b3240
+5 -1
View File
@@ -161,6 +161,8 @@ export const getDefaultPubkeys = () => {
return userPubkeys.length > 5 ? userPubkeys : [...userPubkeys, ...appPubkeys]
}
const failedUnwraps = new Set()
export const ensureUnwrapped = async (event: TrustedEvent) => {
if (event.kind !== WRAP) {
return event
@@ -168,7 +170,7 @@ export const ensureUnwrapped = async (event: TrustedEvent) => {
let rumor = repository.eventsByWrap.get(event.id)
if (rumor) {
if (rumor || failedUnwraps.has(event.id)) {
return rumor
}
@@ -192,6 +194,8 @@ export const ensureUnwrapped = async (event: TrustedEvent) => {
// Send the rumor via our relay so listeners get updated
relay.send("EVENT", rumor)
} else {
failedUnwraps.add(event.id)
}
return rumor