From daf39ce36195cb6073461a5ba503385bf58b8add Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Tue, 7 Oct 2025 19:21:28 -0400 Subject: [PATCH] Improve channel grid loading responsiveness --- js/channelProfile.js | 61 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 11 deletions(-) diff --git a/js/channelProfile.js b/js/channelProfile.js index 396b6a50..3e040a05 100644 --- a/js/channelProfile.js +++ b/js/channelProfile.js @@ -118,6 +118,7 @@ let cachedZapSendBtn = null; let pendingZapRetry = null; let zapInFlight = false; let zapControlsOpen = false; +let currentVideoLoadToken = 0; function getChannelZapButton() { if (cachedZapButton && !document.body.contains(cachedZapButton)) { @@ -1584,13 +1585,32 @@ async function loadUserProfile(pubkey) { */ async function loadUserVideos(pubkey) { const app = getApp(); - try { - try { - await accessControl.ensureReady(); - } catch (error) { - console.warn("Failed to ensure admin lists were loaded before channel fetch:", error); - } + const container = document.getElementById("channelVideoList"); + const loadToken = ++currentVideoLoadToken; + const hadExistingContent = + !!container && container.querySelector("[data-video-id]"); + if (container) { + container.dataset.loading = "true"; + if (!hadExistingContent) { + container.innerHTML = ` +
No videos to display.
`; return; } + container.dataset.hasChannelVideos = "true"; const fragment = document.createDocumentFragment(); const allKnownEventsArray = Array.from(nostrClient.allEvents.values()); @@ -2134,7 +2162,18 @@ async function loadUserVideos(pubkey) { }); }); } catch (err) { + if (loadToken === currentVideoLoadToken && container) { + container.dataset.hasChannelVideos = "false"; + container.innerHTML = ` +Failed to load videos. Please try again.
+ `; + } console.error("Error loading user videos:", err); + } finally { + await ensureAccessPromise; + if (loadToken === currentVideoLoadToken && container) { + delete container.dataset.loading; + } } }