Merge branch 'unstable' into perf/optimize-profile-cache-clear-12083998581018615887

This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-05 15:32:58 -05:00
commit 2b81d9524e
1 file changed
+24 -22
+24 -22
View File
@@ -1908,30 +1908,32 @@ class WatchHistoryManager {
const chunkEvents = Array.isArray(results)
? results.flat().filter((event) => event && typeof event === "object")
: [];
const decryptionPromises = chunkEvents.map(async (event) => {
const ciphertext = typeof event.content === "string" ? event.content : "";
if (!ciphertext) {
return [];
}
let plaintext = "";
if (typeof decryptSigner.nip04Decrypt === "function") {
try {
plaintext = await decryptSigner.nip04Decrypt(actorKey, ciphertext);
} catch (error) {
devLogger.warn("[nostr] Failed to decrypt watch history chunk:", error);
const chunkResults = await pMap(
chunkEvents,
async (event) => {
const ciphertext = typeof event.content === "string" ? event.content : "";
if (!ciphertext) {
return [];
}
let plaintext = "";
if (typeof decryptSigner.nip04Decrypt === "function") {
try {
plaintext = await decryptSigner.nip04Decrypt(actorKey, ciphertext);
} catch (error) {
devLogger.warn("[nostr] Failed to decrypt watch history chunk:", error);
}
}
if (!plaintext) {
return [];
}
const parsed = parseWatchHistoryPayload(plaintext);
if (Array.isArray(parsed.items) && parsed.items.length) {
return parsed.items;
}
}
if (!plaintext) {
return [];
}
const parsed = parseWatchHistoryPayload(plaintext);
if (Array.isArray(parsed.items) && parsed.items.length) {
return parsed.items;
}
return [];
});
const chunkResults = await Promise.all(decryptionPromises);
},
{ concurrency: 5 },
);
decryptedItems.push(...chunkResults.flat());
} catch (error) {
devLogger.warn("[nostr] Failed to fetch watch history chunks:", error);