From 79cc6b8ba553d36e354861d2c48d106ffe3d01dc Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Tue, 14 Oct 2025 13:42:21 -0400 Subject: [PATCH] Ensure channel profile fetch initializes relay pool --- js/channelProfile.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/js/channelProfile.js b/js/channelProfile.js index 0fd58241..fd4d93c5 100644 --- a/js/channelProfile.js +++ b/js/channelProfile.js @@ -2158,12 +2158,27 @@ function applyChannelProfileMetadata({ } async function fetchChannelProfileFromRelays(pubkey) { - if (!nostrClient?.pool || !Array.isArray(nostrClient?.relays)) { + try { + await nostrClient.ensurePool(); + } catch (error) { + console.error("Failed to initialize relay pool for channel profile:", error); + return { event: null, profile: {} }; + } + + const pool = nostrClient?.pool; + const relayCandidates = Array.isArray(nostrClient?.relays) + ? nostrClient.relays.filter( + (relayUrl) => typeof relayUrl === "string" && relayUrl.trim().length > 0 + ) + : []; + const relayUrls = relayCandidates.length > 0 ? relayCandidates : DEFAULT_RELAY_URLS; + + if (!pool || !Array.isArray(relayUrls) || relayUrls.length === 0) { return { event: null, profile: {} }; } try { - const events = await nostrClient.pool.list(nostrClient.relays, [ + const events = await pool.list(relayUrls, [ { kinds: [0], authors: [pubkey], limit: 1 } ]);