From fc8a89d2fa779214c87fd69ba764f4f1b73d0e8c Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Wed, 27 May 2026 19:20:07 -0400 Subject: [PATCH] Community browser: auto-refresh on open + longer relay timeouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three reported issues: 1. "When I click the button it should auto-refresh." The two Browse- Community buttons opened the modal and called switchModalTab('New'), which routes to loadFeedTab. fetchFeedAndReactions honours a 5-minute cache (line 16310), so a user reopening the browser within that window saw stale results — including not seeing their own design they just published. Add invalidateFeedCache() before opening the modal so the 5-minute cache is bypassed on every Browse click. Applied to both #browseCommunityBtn and #designerBrowseCommunityBtn. 2. "Sometimes it does not load everything in correctly each time." The relay fetch timeouts were tight enough that slow relays would miss reply windows. Bump: - templates: 4500ms → 6000ms - deletions: 3500ms → 5000ms - reactions: 2500ms → 4000ms - zap receipts: 4500ms → 6000ms Streaming via onEvent is unaffected, so the first event still appears the moment any relay responds; the longer ceiling just means more events make the cut before the await resolves. 3. "Zap and up-vote ranking is not working reliably." The sort logic in loadFeedTab is correct — Popular sorts by zap total, then reactions, then trust, then date; Zapped sorts purely by zap total. Reactions are fully fetched before the initial rerender; zap receipts stream in asynchronously and trigger debounced rerenders via scheduleZapStreamRerender → notifyFeedProgress, which re-sorts using the now-current _zapCache. So unreliable perception was mostly "I see initial sort, then it reorders." The fix here is indirect — longer zap timeout + auto-refresh on open mean more zaps arrive within the first rerender window, so the user sees the correct order sooner instead of watching it shuffle. Co-Authored-By: Claude Opus 4.7 --- src/index.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/index.html b/src/index.html index 78dc0bd..89120bd 100644 --- a/src/index.html +++ b/src/index.html @@ -16349,8 +16349,8 @@ try { await Promise.all([ - queryRelays(relays, { kinds: [30078], '#t': ['casewrap'], limit: 200 }, { timeoutMs: 4500, onEvent: onIncoming, onRelayDone: onTemplateRelayDone }), - queryRelays(relays, { kinds: [5], '#k': ['30078'], limit: 100 }, { timeoutMs: 3500, onEvent: onIncoming }) + queryRelays(relays, { kinds: [30078], '#t': ['casewrap'], limit: 200 }, { timeoutMs: 6000, onEvent: onIncoming, onRelayDone: onTemplateRelayDone }), + queryRelays(relays, { kinds: [5], '#k': ['30078'], limit: 100 }, { timeoutMs: 5000, onEvent: onIncoming }) ]); _feedCache.phase = 'enrichment'; flushProgress(); @@ -16361,7 +16361,7 @@ const BATCH = 50; const reactionRequests = []; for (let i = 0; i < ids.length; i += BATCH) { - reactionRequests.push(queryRelays(relays, { kinds: [7], '#e': ids.slice(i, i + BATCH) }, { timeoutMs: 2500 })); + reactionRequests.push(queryRelays(relays, { kinds: [7], '#e': ids.slice(i, i + BATCH) }, { timeoutMs: 4000 })); } const reactionBatches = await Promise.all(reactionRequests); for (const rxEvents of reactionBatches) { @@ -17558,7 +17558,7 @@ for (let i = 0; i < fresh.length; i += CHUNK) chunks.push(fresh.slice(i, i + CHUNK)); await Promise.all(chunks.map(ids => queryRelays(relays, { kinds: [9735], '#e': ids, limit: 500 }, { - timeoutMs: 4500, + timeoutMs: 6000, onEvent: ev => { if (ingestZapReceipt(ev)) { mutated = true; scheduleZapStreamRerender(); } } @@ -22048,6 +22048,10 @@ btn.classList.toggle('active', btn.dataset.type === 'any'); }); } + // Auto-refresh on open. fetchFeedAndReactions otherwise honours a + // 5-minute cache and the user would see stale results (including + // their own design they just published). + invalidateFeedCache(); $('nostrModal').classList.add('open'); switchModalTab('New'); }); @@ -22059,6 +22063,7 @@ btn.classList.toggle('active', btn.dataset.type === 'disc-design'); }); } + invalidateFeedCache(); $('nostrModal').classList.add('open'); switchModalTab('New'); });